Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

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

Status
Not open for further replies.

JaniseD

Programmer
Aug 9, 2013
2
US
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?
 
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.type == "select-multiple"){
var selectBox = theForm.elements;
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;
}
}

}
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top