Answered
setting default value in dynamic drop-down menu
Hi,
I created a simple drop-down menu that can be used to edit an existing record or to create a new record.
When creating a new record, I'd like the drop-down menu to display "Not specified" by default. Could anyone help me with this?
The "Not specified" option in the drop-down menu should refer to record ID 11 in my database table entitled "names".
Here's what my code looks like so far.
The db queries:
<CFQUERY DATASOURCE="DATA" NAME="get">
SELECT *
FROM names
order by name
</CFQUERY>
<CFQUERY DATASOURCE="DATA" NAME="quo">
SELECT *
FROM quotes
WHERE quoteID = #quoteID#
</CFQUERY>
This part is for the existing database record:
<select name="frn_ID">
<cfoutput query="get">
<option value="#id#"<cfif id is quo.frn_ID> selected</cfif>>#name#</option>
</cfoutput>
</select>
Here is where I'd like the ID with a default value of 11 to be displayed:
<cfelse>
<select name="frn_ID">
<cfoutput query="get">
<option value="#id#">#name#</option>
</cfoutput>
</select>
</cfif>
Thank you for any help with this!
Luke
I created a simple drop-down menu that can be used to edit an existing record or to create a new record.
When creating a new record, I'd like the drop-down menu to display "Not specified" by default. Could anyone help me with this?
The "Not specified" option in the drop-down menu should refer to record ID 11 in my database table entitled "names".
Here's what my code looks like so far.
The db queries:
<CFQUERY DATASOURCE="DATA" NAME="get">
SELECT *
FROM names
order by name
</CFQUERY>
<CFQUERY DATASOURCE="DATA" NAME="quo">
SELECT *
FROM quotes
WHERE quoteID = #quoteID#
</CFQUERY>
This part is for the existing database record:
<select name="frn_ID">
<cfoutput query="get">
<option value="#id#"<cfif id is quo.frn_ID> selected</cfif>>#name#</option>
</cfoutput>
</select>
Here is where I'd like the ID with a default value of 11 to be displayed:
<cfelse>
<select name="frn_ID">
<cfoutput query="get">
<option value="#id#">#name#</option>
</cfoutput>
</select>
</cfif>
Thank you for any help with this!
Luke
