Link to home
Start Free TrialLog in
Avatar of lulu50
lulu50Flag for United States of America

asked on

Reselect my selected multi select list

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

ASKER CERTIFIED SOLUTION
Avatar of gdemaria
gdemaria
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
Avatar of lulu50

ASKER

Excellentooooooo !!!!!!!!!!!!

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