×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

CF Multi-Select Box Not Displaying Values Passed From Grid?

CF Multi-Select Box Not Displaying Values Passed From Grid?

CF Multi-Select Box Not Displaying Values Passed From Grid?

(OP)
Coldfusion 8

I inherited an application and am trying to maintain and improve it... hit a snag today.


I have a multi-select box that is not displaying what I expect. The values come from a ColdFusion grid which is based off a database query.

Here is the code for the select - does not work - nothing is selected:


<cfselect name="USER_IDS" multiple="true" queryposition="below" selected="USER_IDS" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >

</cfselect>


Now if I change the multiselect to a single select like below - it takes the first item in the field list (from the grid) and selects it in the drop down.

<cfselect name="USER_IDS" multiple="false" queryposition="below" selected="USER_IDS" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >

</cfselect>


Or if I assign a variable like this and use the multi-select code it seems to work as well.




testlist = "22,26";


...

<cfselect name="USER_IDS" multiple="true" queryposition="below" selected="#testlist#" query="ActiveUsersPlus" disabled="#disabled#" value="G_USER_WORK_UNIT_SK" display="G_USER_ID" >

</cfselect>


I have displayed the value of "User_IDs" in the grid and in the data entry part of the screen to see values of: 22,26

to make sure that wasn't my issue.


Do grids and multiselects require something additional? Any advice on how to resolve?

RE: CF Multi-Select Box Not Displaying Values Passed From Grid?

(OP)
Problem was in some javascript - there was code for a single select box but not for a multiple select box. This JS fixed my issue.

if(theForm.elements[i].type == "select-multiple"){
var selectBox = theForm.elements[i];
var sbname = selectBox.name;

cpvalue = String(eval('record.data.' + sbname));
//alert(cpvalue);
//alert(Object.prototype.toString.call(cpvalue));

var NotifyArray = cpvalue.split(',');
for (var j=0; j < selectBox.length; j++) {
selectBox[j].selected = false;
}
for (var j=0; j < selectBox.length; j++) {
sbvalue = selectBox[j].value;
for (var k=0; k < NotifyArray.length; k++){
if (sbvalue == NotifyArray[k]){
selectBox[j].selected = true;
}
}

}
}

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close