Solved

Retaining values in multi select box

Posted on 2006-11-07
7
271 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
Create the perfect environment for any meeting

You might have a modern environment with all sorts of high-tech equipment, but what makes it worthwhile is how you seamlessly bring together the presentation with audio, video and lighting. The ATEN Control System provides integrated control and system automation.

 
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

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

One of the typical problems I have experienced is when you have to move a web server from one hosting site to another. You normally prepare all on the new host, transfer the site, change DNS and cross your fingers hoping all will be ok on new server…
Periodically we have to update or add SSL certificates for customers. Depending upon your hosting plan you may be responsible for the installation and/or key generation. In the wake of Heartbleed many sites were forced to re-key. We will concen…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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…

756 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