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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Drop Down Menu Dynamic Links?

Status
Not open for further replies.

EndaD

Technical User
May 7, 2002
1
IE
Hi,

I have created a drop down menu form which connects dynamically to a DB table. The table contains 2 fields, the ID and County. What I want to be able to do with the drop down menu is use the counties it lists as hyperlinks to that particular counties page, ie select a scroll to a particlur county on the menu, click on submit and up comes the relevant page but all I keep getting is the same county - ie the one with an ID of 1. I've tried passing a variable to assume the name of the county but nothing works. My code is below -where am I going wrong? Appreciate any Help!
Enda D

<% Set country=Server.CreateObject (&quot;ADODB.Recordset&quot;)
country.open &quot;SELECT * FROM county WHERE 'ID' IS > 0&quot;,&quot;DSN=country&quot;
%>
<%
LinkName=country(&quot;county&quot;)&&quot;.asp&quot;
%>

<form Method=&quot;GET&quot; action=&quot;<%=LinkName%>&quot;>
<p><select size=&quot;1&quot; name=&quot;county&quot;>
<% DO WHILE not country.EOF %>
<option value=&quot;<%=country(&quot;ID&quot;)%>&quot;><%=country(&quot;County&quot;)%></option>
<%
country.MoveNext
Loop
country.Close
Set country=Nothing
%>
</select><input type=&quot;submit&quot; value=&quot;Go!&quot; name=&quot;B1&quot;></p>
</form>
 
The reason you keep going to the first county is in the form tag. You set the first record to be the action of the form: <form Method=&quot;GET&quot; action=&quot;<%=LinkName%>&quot;>. No matter what county you choose from the dropdown, the action will remain the first county. Instead of using a submit input type, use a button to call a javascript function. The function should look something like this:

function GoCounty()
{
document.formname.action = document.formname.county.value + &quot;.asp&quot;;
document.formname.submit();
}

Be sure to give you form a name in the form tag also.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top