Click to See Complete Forum and Search --> : Form Dropdown Anchor


caryyy
03-09-2006, 08:11 AM
I'm trying to make a dropdown box in a form. I want all the options in the dropdown box to link to a named anchor on the same page, but I can't get it to work. Here's the code I'm using:

<form>
<div align="left">
<select name="memnur" onChange="location.href=(form.memnur.options[form.memnur.selectedIndex].value)" style="font-family: verdana;">
<option value="">Alphabetical Index</option>
<option value="#a">A</option>
<option value="#b">B</option>
<option value="#c">C</option></select>
</div></caption></form>

<a name="a"></a>
<a name="b"></a>
<a name="c"></a>

The actual page is here: http://www.pbfngla.com/home/members-nursery.htm

Kravvitz
03-09-2006, 08:21 AM
You need to use location.hash, not location.href.
Event names are all lower case.
You can use "this" instead of "form.memnur".

Change
onChange="location.href=(form.memnur.options[form.memnur.selectedIndex].value)"
to
onchange="location.hash=this.options[this.selectedIndex].value;"

caryyy
03-09-2006, 08:40 AM
Thanks. I replaced the string as suggested, but it still doesn't work. When I choose a dropdown option on the page, it doesn't do anything.

Kravvitz
03-09-2006, 01:39 PM
I suggest that you fix your HTML errors. (http://validator.w3.org/check?verbose=1&uri=http%3A%2F%2Fwww.pbfngla.com%2Fhome%2Fmembers-nursery.htm%23LetterB)

caryyy
03-09-2006, 01:44 PM
I resolved the problem. The code was right, but I placed the <a name="xyz"></a> in between a </tr> and <tr> tag like this:

</tr>
<a name="xyz"></a>
<tr>

and apparently it wasn't visible there.

I moved it like this and the problem is fixed:

</tr>
<tr><a name="xyz"></a>