Solved

Retaining values in multi select box

Posted on 2006-11-07
7
270 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
  • 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
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.

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

828 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