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!

dropdown problem

Status
Not open for further replies.

izachar

Technical User
Oct 7, 2000
84
CA
I have 2 drop down menus. The first one is hard coded and based on what you choose there the page refreshes and then populates a second dropdown dynamically. But when the page refreshes the second time to pull the relevant content from the db the second dropdown resets without staying on the value that was chosen. I tried to do the similar as I did in the first drop down but it selects the last dynamic element. any suggestions?

<form name=&quot;form1&quot; method=&quot;post&quot; action=&quot;&quot;>
<select name=&quot;category&quot; onchange=&quot;if((w=this.options[this.selectedIndex].value) !='')window.location = w&quot;>
<option <cfif not isdefined (&quot;category&quot;)>selected</cfif> value=&quot;&quot; >Select a category</option>
<option <cfif category eq &quot;arts&quot;>selected</cfif> value=&quot;search.cfm?category=arts&quot;>Arts</option>
<option <cfif category eq &quot;classified&quot;>selected</cfif> value=&quot;search.cfm?category=classified&quot;>Classified</option>
<option <cfif category eq &quot;comics&quot;>selected</cfif> value=&quot;search.cfm?category=comics&quot;>Comics</option>
<option <cfif category eq &quot;features&quot;>selected</cfif> value=&quot;search.cfm?category=features&quot;>Features</option>
<option <cfif category eq &quot;h2&quot;>selected</cfif> value=&quot;search.cfm?category=h2&quot;>Pg. 2</option>
<option <cfif category eq &quot;news&quot;>selected</cfif> value=&quot;search.cfm?category=news&quot;>News</option>
<option <cfif category eq &quot;sports&quot;>selected</cfif> value=&quot;search.cfm?category=sports&quot;>Sports</option>
</select>

</cfoutput>

<cfif category neq &quot;&quot;>
<select name=&quot;category&quot; onchange=&quot;if((w=this.options [this.selectedIndex].value) !='')window.location = w&quot;>

<cfif category eq #category#>
<cfquery datasource=#datasource# username=#username# password=#password# name=#category#>
select distinct (#category#_date) as date
from #category#
where #category#_date < #prevwednesday#
and #category#_active like 'yes%%'
</cfquery>



<option selected value=&quot;&quot;>Select a date</option>
<cfoutput query=&quot;#category#&quot;>
<option value=&quot;search.cfm?category=#category#&date=#date#&quot;>
#dateformat(date,&quot;mm/dd/yyyy&quot;)#</option>
</cfoutput>



</select>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top