Skip to main content
Participant
August 8, 2013
Answered

Multi-Select Box Not Displaying Values Passed From Grid?

  • August 8, 2013
  • 1 reply
  • 503 views

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?

This topic has been closed for replies.
Correct answer Janise123

Problem was related to some javascript for the select box.  There was a function for a single select box but not a multiple select box - this fixed it: 

if(theForm.elements.type == "select-multiple"){

                    var selectBox = theForm.elements;

                    var sbname = selectBox.name;

                   

                    cpvalue = String(eval('record.data.' + sbname));

                   

                    var NotifyArray = cpvalue.split(',');

                    for (var j=0; j < selectBox.length; j++) {

                        selectBox.selected = false;

                    }

                    for (var j=0; j < selectBox.length; j++) {

                        sbvalue = selectBox.value;

                        for (var k=0; k < NotifyArray.length; k++){

                            if (sbvalue == NotifyArray){

                                selectBox.selected = true;

                            }

                        }

                    }

                }

1 reply

Janise123AuthorCorrect answer
Participant
August 12, 2013

Problem was related to some javascript for the select box.  There was a function for a single select box but not a multiple select box - this fixed it: 

if(theForm.elements.type == "select-multiple"){

                    var selectBox = theForm.elements;

                    var sbname = selectBox.name;

                   

                    cpvalue = String(eval('record.data.' + sbname));

                   

                    var NotifyArray = cpvalue.split(',');

                    for (var j=0; j < selectBox.length; j++) {

                        selectBox.selected = false;

                    }

                    for (var j=0; j < selectBox.length; j++) {

                        sbvalue = selectBox.value;

                        for (var k=0; k < NotifyArray.length; k++){

                            if (sbvalue == NotifyArray){

                                selectBox.selected = true;

                            }

                        }

                    }

                }