Solved

Retaining values in multi select box

Posted on 2006-11-07
7
266 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Suggested Solutions

A web service (http://en.wikipedia.org/wiki/Web_service) is a software related technology that facilitates machine-to-machine interaction over a network. This article helps beginners in creating and consuming a web service using the ColdFusion Ma…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

707 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now