try this on for size

<SELECT name="project">
<CFOUTPUT query="get_projects">
<OPTION value="#ID#"<cfif ID is get_details.ID> selected</cfif>>#projectname#</OPTION>
</CFOUTPUT>
</SELECT>
  ----- Original Message -----
  From: Chris Kavanagh
  To: CF-Talk
  Sent: Wednesday, August 18, 2004 8:33 PM
  Subject: setting a default value in my SELECT tag

  Dear list,

  I'm sure there is a simple answer to this basic question.  Sorry for
  being such a noob: I'm working on my first application!  I hope to
  become a useful member of the CF community one day.  But first you will
  have to put up with my stupid questions for a while.

  Stupid question the second: I have a <select> element in a form.  The
  options are populated from a database.  It looks a bit like this:

  <CFQUERY name="get_projects" datasource="datasource">
  SELECT projectname FROM projects
  </CFQUERY>

  ...

  <SELECT name="project">
  <CFOUTPUT query="get_projects">
  <OPTION>#projectname#</OPTION>
  </CFOUTPUT>
  </SELECT>

  It works beautifully so far, giving me a list of all the projects in my
  database.  But I'd like it to default to a certain value from another
  query.  So I added some more code:

  <CFQUERY name="get_details" datasource="datasource">
  SELECT projectname FROM projects
  WHERE ID=[a certain value]
  </CFQUERY>

  <CFOUTPUT query="get_details">
  <SELECT name="project" value="#projectname#">
  </CFOUTPUT>
  <CFOUTPUT query="get_projects">
  <OPTION>#projectname#</OPTION>
  </CFOUTPUT>
  </SELECT>

  But it just doesn't work: it won't default to the value from the new
  query.  Am I being a total moron?

  TIA,
  CK.
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings] [Donations and Support]

Reply via email to