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

asked on

If found in a list

Hi,

I have a multi select box with checkboxes to multi select from
If I select more than one and clicked on submit the page should reload the previous submition.

this is what I have so far:

<cfquery name="VersionList" datasource="#xx#" username="#xx#" password="#xxx#">
select distinct Version from TestingRules
order by Version asc
</cfquery>

<cfset TempFoundVersionList = "">
<cfif StructKeyExists(Form,'Version') && #form.Version# neq "">
	<cfloop index="vl" list="#form.Version#">
 		<cfif listFind(TempFoundVersionList,vl) eq 0> 
     		<cfset TempFoundVersionList = listAppend(TempFoundVersionList,vl)>
 		</cfif> 
	</cfloop> 
     
 <cfset FoundVersionList = #listQualify(TempFoundVersionList,"'")#> 



      //the output for form.Version :    V9.82,V9.83E 
                
            
<select multiple="multiple" name="Version" id="Version" class="FilterSelect" style="width:270px">
	<CFIF isDefined("VersionList") and #VersionList.RecordCount# gt 0>
     	<cfoutput query="VersionList">
     	<cfif #VersionList.Version# eq #form.Version#>
     		<option value="#VersionList.Version#"  <cfif ListFindNoCase(FoundVersionList)> selected="selected" </cfif> >#VersionList.Version#</option>
     	<cfelse>
     		<option value="#VersionList.Version#">#VersionList.Version#</option>
     	</cfif>
        </cfoutput>
     <cfelse>
     	<cfoutput query="VersionList">
      		<option value="#VersionList.Version#">#VersionList.Version#</option>
      	</cfoutput>
     </CFIF>
		</select>

Open in new window



Thank you,
Lulu
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
Avatar of lulu50

ASKER

It is only selecting the ones that I select but it also need to display the other version in the list that have not been selected

this is what I have

<select multiple="multiple" name="Version" id="Version" class="FilterSelect" style="width:270px">
	<CFIF (isDefined("VersionList") and #VersionList.RecordCount# gt 0) and (isDefined("form.Version")) >
       	<cfloop list="#form.Version#" index="k" delimiters=",">
     	<cfoutput> 	
            	<cfif not #listfind(FoundVersionList,k)#>		
        			<option value="#k#" selected="selected">111 #k#</option>
               <cfelse> 
     			    <option value="#k#">2222 #k#</option> 
        		</cfif>
        </cfoutput>        
        </cfloop> 
    <cfelse>
     	<cfoutput query="VersionList">
      		<option value="#VersionList.Version#">333 #VersionList.Version#</option>
       </cfoutput>
    </CFIF>
		</select> 

Open in new window

Avatar of lulu50

ASKER

I can't get it to work,

I'm not sure what I'm doing wrong.


<select multiple="multiple" name="Version" id="Version" class="FilterSelect" style="width:270px">
	<CFIF (isDefined("VersionList") and #VersionList.RecordCount# gt 0) and (isDefined("form.Version")) >
	<cfloop index="x" list="#form.Version#">
 		<cfif listFind(VersionList.Version,x) eq #x#> 
     		<option value="<cfoutput>#x#</cfoutput>" selected="selected">111 <cfoutput>#x#</cfoutput></option>
            <cfelse>
            <option value="<cfoutput>#x#</cfoutput>" >222 <cfoutput>#x#</cfoutput></option>
 		</cfif> 
	</cfloop> 
 <cfelse>
     	<cfoutput query="VersionList">
      		<option value="#VersionList.Version#">333 #VersionList.Version#</option>
       </cfoutput>
    </CFIF> 
		</select> 

Open in new window

Avatar of lulu50

ASKER

Ah  after many try and changes

I got it to work!!!!

Thank you

<select multiple="multiple" name="Version" id="Version" class="FilterSelect" style="width:270px">
 <cfoutput query="VersionList">
	<option value="#VersionList.Version#" <cfif ListFind(form.Version,VersionList.Version)>
 selected="selected" </cfif> >
 #VersionList.Version#
 </option>
 </cfoutput>
 </select>

Open in new window

Avatar of lulu50

ASKER

Thank you
Sorry I was out, glad you got it to work!