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
lulu50Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

gdemariaCommented:
I'm having a little trouble following the code, so I thought I would illustrate how do to multiple selects using an example.   This is a list of all types of dogs, and another query that shows the dogs that I own.   The select will show all dogs and select just the ones that I own..

	
<!---- this is a list of just the dogs that I own ---->
<cfquery name="MyDogs" datasource="#request.datasource#">
  select dog_id from myDogs where dogOwner_id = #myUserId#
</cfquery>
<cfset myDogIds = valueList(myDogs.dog_id)>
		
		
<!--- this is a list of all dogs ---->
<cfquery name="AllDogs" datasource="#request.datasource#">
  select dog_id, dogName from dogs
</cfquery>


<!--- this select box will show all dogs, and check off the dogs that I own ---->
<select name="dog_id" multiple>
  <cfloop query="AllDogs">
    <option value="#allDogs.dog_id#" <cfif listFind(myDogIds,allDogs.dog_id)>selected</cfif> >#allDogs.dogName </option>
  </cfloop>
</select>

Open in new window



Sorry if I missed the point, but I am not sure what all your code is trying to do.. maybe add some comments if you need more help?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
lulu50Author Commented:
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

0
lulu50Author Commented:
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

0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

lulu50Author Commented:
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

0
lulu50Author Commented:
Thank you
0
gdemariaCommented:
Sorry I was out, glad you got it to work!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ColdFusion Language

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.