Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamic Multiple Select Menu - Multiple Options Selected 1

Status
Not open for further replies.

peter11

Instructor
Mar 16, 2001
334
US
I am creating an edit page for coaches. I have a multiple select that generates and works fine. I am trying to make options in the menu "selected" according to a separate query (currentpos). The problem comes when the currentpos query generates more than one match (meaning two or more options should be selected). I tried to put a cfloop inside the option tag but that does not work.

Code:
<cfquery datasource="paper" name="pos">
select posname,posid from spcoachpos 
</cfquery>
						
<cfquery datasource="paper" name="currentPos">
select posid, userid from spCoachAssign
where userid = #eduser.userid# 
</cfquery>
						
<select name="posid" id="posid" multiple size = "6">
<option value = "0">None</option>
<cfloop query="pos">
<option [b]<cfloop query= "currentpos">[/b] <cfif pos.posid is currentpos.posid> selected </cfif> </cfloop> value="#pos.posid#" >  #pos.posname#</option>
</cfloop>
</select>
 
what does "does not work" mean? crashes the server? issues an error message? hangs indefinitely? returns easy-to-prepare guacamole recipes?

:)

r937.com | rudy.ca
 
Sorry,
no options are selected.
also when previewing in dreamweaver the cfloop tag I highlighted is orange instead of the burgandy that all cf tags are.
 
try this --
Code:
<select name="posid" id="posid" 
    multiple size = "6">
<option value="0">None</option>
<cfloop query="pos">
[b]<cfset tempvariable=pos.posid>[/b]
<option 
  <cfloop query= "currentpos"> 
   <cfif currentpos.posid 
      eq [b]tempvariable[/b]> selected </cfif> 
  </cfloop> 
  value="#pos.posid#" 
    >  #pos.posname#</option>
</cfloop>
</select>

r937.com | rudy.ca
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top