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

Onchange - why isn't this working?

Status
Not open for further replies.

GirlFriday1

Programmer
May 1, 2001
20
CA
Hello there!
I have a drop down box with that is populated using a database. This is the code:

<SELECT NAME=&quot;User&quot;>
<option value=&quot;<%=Request.Servervariables(&quot;SCRIPT_NAME&quot;)%>&quot; selected>-- Select --</option>
<% While not RS2.EOF %>
<option value=&quot;<%=RS2.Fields(&quot;id&quot;)%>&quot;
<%
if Userid = RS2.Fields(&quot;id&quot;) then
Response.Write &quot;SELECTED&quot;
UserInfo = RS2.Fields(&quot;Last Name&quot;) & &quot;, &quot; & RS2.Fields(&quot;First Name&quot;) & &quot; &quot;
UserInfo2 = RS2.Fields(&quot;Department Name&quot;) & &quot; &quot;
UserInfo3 = RS2.Fields(&quot;Phone Number&quot;) & &quot; &quot;
UserInfo4 = RS2.Fields(&quot;Email Address&quot;) & &quot; &quot;
end if
%>
><
%=RS2.Fields(&quot;Last Name&quot;)%> ,   <%=RS2.Fields(&quot;First Name&quot;)%></option>
<% RS2.MoveNext
Wend %>
</SELECT>
As you can see, it is in both JScript and ASP. The problem is I don't want the user to get an error message if they select the Select option. This isn't really an option.. I thought that something like

<select name=&quot;URL&quot; size=&quot;1&quot; onchange=&quot;if(options[selectedIndex].value) window.location.href= (options[selectedIndex].value)&quot;>

would work, but alas, no dice.
Any suggestions?
Thanks,
Shelli
 
I would suggest ,

<select name=&quot;URL&quot; onchange=javascript:jump()>
...
...
</select>


and at the top of the page b4 the <body> tag put in
<script>
function jump()
{
if(options[selectedIndex].value)
{
window.location.href=(options[selectedIndex].value)
}
}
</script>


Let me know how you get on. DeltaFlyer ;-)

DeltaFlyer - The Only Programmer To Crash With [colo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top