Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Dynamic Population

How do I select a default value in a dynamicaly populated dropdown (<select>)? by TruthInSatire
Posted: 27 Jan 04 (Edited 7 Mar 05)

<!--- this query will get the data to populate the select box--->
<cfquery datasource="#datasource#" name="qSelectData">
    SELECT Item, Value
    FROM ItemTable
    ORDER BY Item

<!--- Create a variable to use as the value you want to select. this could be the value of a seperate query, session variable, form variable, or anything you wish to compair.  --->
<cfset defaultValue = "mySelectedItem">
 <select name="ItemMenu">
    <option value="">Choose Item</option>
    <cfoutput query="qSelectData">

      <!--- Inside the option tag check to see
      if the value of the loop is the value
       you want to display. --->

      <option value="#Value#"
        <cfif qSelectData.Value eq defaultValue>


If the values in the <cfif>...</cfif> match the produced output will look something like:
<option value = "mySelectedItem" selected>item</option>

Back to Adobe FAQ Index
Back to Adobe Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close