Solved

Reselect my selected multi select list

Posted on 2014-03-25
3
238 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
Comment Utility
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:myselfrandhawa
Comment Utility
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
Comment Utility
Excellentooooooo !!!!!!!!!!!!

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

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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

6 Experts available now in Live!

Get 1:1 Help Now