Solved

Reselect my selected multi select list

Posted on 2014-03-25
3
242 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 16

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
The technique is by far very Simple! How we can export the ColdFusion query results to DOC file?  Well before writing this I researched a lot in Internet but did not found a good Answer anyways!  So i thought now i should share my small snippet w…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

773 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