View Single Post
  #1 (permalink)  
Old Mar 24th, 2008, 22:56
Keeldog Keeldog is offline
Junior Member
Join Date: Apr 2007
Location: USA
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Question ColdFusion - Using listboxes - Need Help!

Hi,

I'm having an issue with HTML list boxes and ColdFusion validation. First, here is the query I'm using:

Code: Select all
 
<cfquery name="actor" datasource="ows">
SELECT *
FROM Actors
WHERE ActorID=#URL.ActorID# 
</cfquery>
And I've assigned the database fields I need to local variables with this code:

Code: Select all
<cfset NameFirst=Trim(actor.NameFirst)>
<cfset NameLast=Trim(actor.NameLast)>
<cfset Age=Int(actor.Age)>
<cfset Gender=Trim(actor.Gender)>
Later on, down on my form, I'm using an HTML <select> tag for a list box. Normally, I would just populate the list box from the database using <cfselect>, but in this case I just want to offer the option of "male" or "female."

It needs to be pre-selected so that when an actor's info is pulled up, the correct gender is already selected. This is the code I have:

Code: Select all
 
<select name="Gender">
     <cfoutput>
        <option value="Male" <cfif VARIABLES.Gender IS "Male">Selected</cfif>>Male</option>
        <option value="Female" <cfif VARIABLES.Gender IS "Female">Selected</cfif>>Female</option>
     </cfoutput>
</select>
And it's not working --- I don't know if I need the <cfoutput> tag or not... Anybody know what I'm doing wrong? The query is working, but it won't select the right gender.

Thanks,
- Keeldog
Reply With Quote