Solved

Retaining values in multi select box

Posted on 2006-11-07
7
272 Views
Last Modified: 2013-12-24
I've got a form posting back to itself. User selects one or more values from a multiselect box.  If only one value is selected, on postback the value remains selected.  If more than one value is selected, no values remain selected.

Is there a way to have the multiple selections showing on post back?

Thanks,

JK
0
Comment
Question by:joekus
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 15

Expert Comment

by:danrosenthal
ID: 17891704
Are you doing something like this?

<SELECT name="test" multiple>
  <CFQUERY name="myquery">
    <OPTION value="#value#" <CFIF LISTFIND(form.test,value)>SELECTED</CFIF>>#display#
  </CFQUERY>
</SELECT>
0
 

Author Comment

by:joekus
ID: 17891777
Sorry.  New to ColdFusion and have inherited some of this code...

<cfSELECT NAME="vArea" id="Area" size="3" tabindex="0" multiple = "yes" onchange="javascript:focus(this.selectedIndex);">
    <cfloop from="1" to="9" index="i">
        <cfset anum=#NumberFormat(i,"09")#><cfset aid="a" & #anum#>
        <cfoutput>
            <option  value="#anum#"<cfif IsDefined("form.vArea")  and isdefined("form.Selection") and form.vArea Is #anum# and listfind(form.Selection,qSelect.Area)>selected</cfif>>Area #i#</option>
       </cfoutput>
    </cfloop>
</cfSELECT>
0
 
LVL 15

Accepted Solution

by:
danrosenthal earned 500 total points
ID: 17891831
Not sure exactly what the code is SUPPOSED to do, as I have now idea what form.selection and qselect.Area are for. But here is my best guess:

<CFPARAM name="form.vArea" default="#qSelect.Area#">
<cfSELECT NAME="vArea" id="Area" size="3" tabindex="0" multiple = "yes" onchange="javascript:focus(this.selectedIndex);">
    <cfloop from="1" to="9" index="i">
        <cfset anum=NumberFormat(i,"09")>
            <cfset aid="a" & anum>
        <cfoutput>
            <option  value="#anum#"<cfif listfind(form.vArea,anum)>selected</cfif>>Area #i#</option>
       </cfoutput>
    </cfloop>
</cfSELECT>



0
Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

 
LVL 7

Expert Comment

by:bwasyliuk
ID: 17891838
Not sure where this is evaluating from : listfind(form.Selection,qSelect.Area)

But Dan was pointing you in the right direction.  As I see it, submitting this form will multiple form.vArea values selected will have a #form.vArea# value like "a01,a04,a05" or whatever is selected.

Thus, the code :::::::::  form.vArea Is #anum#
will need to be more like Dan's example::::::::  LISTFIND(form.vArea,anum) > 0

The other condition, however - may still cause you some issues, because it is not obvious what "listfind(form.Selection,qSelect.Area)" will evaluate to.

Ben
www.scheduleforce.net
0
 
LVL 7

Expert Comment

by:bwasyliuk
ID: 17891842
Sorry Dan - was typing while you posted your other comment...
0
 
LVL 15

Expert Comment

by:danrosenthal
ID: 17891912
No problem, looks like we are in agreement anyway :)
0
 

Author Comment

by:joekus
ID: 17891931
Thanks, Dan.  Even with my unclear information you were able to de-cipher it.  Your guess was right on.

Thanks, Ben for clarifying comment.

JK
0

Featured Post

Connect further...control easier

With the ATEN CE624, you can now enjoy a high-quality visual experience powered by HDBaseT technology and the convenience of a single Cat6 cable to transmit uncompressed video with zero latency and multi-streaming for dual-view applications where remote access is required.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
If you don't have the right permissions set for your WordPress location in IIS, you won't be able to perform automatic updates. Here's how to fix the problem.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question