Solved

Reselect my selected multi select list

Posted on 2014-03-25
3
241 Views
Last Modified: 2014-03-26
Hi,

I have a multi select list that I insert into my table.

What I want is to reselect the list if I'm passing the ID for editing.


 <SELECT multiple="multiple" name="SelectDepartmentImpacted" id="SelectDepartmentImpacted" style="width:500px;height:130px;" class="SearchBySelect5"> 
           <cfoutput query="QDepartmentImpacted">
            <CFIF isDefined("QSelectedDepartmentJoint") and #QSelectedDepartmentJoint.RecordCount# gt 0>
    
       <cfif #QDepartmentImpacted.DepartmentImpactedID# eq #QSelectedDepartmentJoint.DepartmentImpactedID# >
     		 			<option value="#QDepartmentImpacted.DepartmentImpactedID#" selected="selected">#QDepartmentImpacted.Department#</option>
     				<cfelse>
     		 			<option value="#QDepartmentImpacted.DepartmentImpactedID#">#QDepartmentImpacted.Department#</option>
     				</cfif>
       <cfelse>
       			  <option value="#QDepartmentImpacted.DepartmentImpactedID#">#QDepartmentImpacted.Department#</option>
       </CFIF>
			 </cfoutput>
            </select> 

Open in new window

0
Comment
Question by:lulu50
3 Comments
 
LVL 39

Accepted Solution

by:
gdemaria earned 500 total points
ID: 39954935
I made a comma delimited list of all the selected Department IDs  - the list is in the variable AllIDs.

Then I compare the departmentID to the list, if the ID is on the list, then it is selected, if not, it is not selected.

Does this work?

<cfset AllIDs = valueList(QSelectedDepartmentJoint.DepartmentImpactedID)>
<SELECT multiple="multiple" name="SelectDepartmentImpacted" id="SelectDepartmentImpacted" style="width:500px;height:130px;" class="SearchBySelect5"> 
	<cfoutput query="QDepartmentImpacted">
		<cfif listFind(AllIDs,QDepartmentImpacted.DepartmentImpactedID)>
			<option value="#QDepartmentImpacted.DepartmentImpactedID#" selected="selected">#QDepartmentImpacted.Department#</option>
		<cfelse>
			<option value="#QDepartmentImpacted.DepartmentImpactedID#">#QDepartmentImpacted.Department#</option>
		</cfif>
	</cfoutput>
</select> 

Open in new window

0
 
LVL 15

Expert Comment

by:Gurpreet Singh Randhawa
ID: 39955350
It will be like this:


<cfset AllIDs = ValueList(QSelectedDepartmentJoint.DepartmentImpactedID)>
<SELECT multiple="multiple" name="SelectDepartmentImpacted" id="SelectDepartmentImpacted" style="width:500px;height:130px;" class="SearchBySelect5">
  <cfloop query="QDepartmentImpacted">
    <option value="#QDepartmentImpacted.DepartmentImpactedID#" <cfif ListContainsNoCase(AllIDs,QDepartmentImpacted.DepartmentImpactedID)>selected</cfif>>#QDepartmentImpacted.Department#</option>
  </cfloop>
</select>

Open in new window


@gdmeria code is also right
0
 

Author Closing Comment

by:lulu50
ID: 39955860
Excellentooooooo !!!!!!!!!!!!

Thank you Thank you and just one more Thank you lol lol
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
Today, I was working on some optimization and spam-stopping techniques when I encountered Ben Nadel's post to reduce spam feature using Math (http://www.bennadel.com/blog/197-How-I-Stop-Spammers-On-My-ColdFusion-Blog.htm). While this method is not o…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

863 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

28 Experts available now in Live!

Get 1:1 Help Now