Jump to content

Creating a link to anchor text using javascript pull-down


9999

Recommended Posts

This is how my pull-down looks:

 

SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function formHandler(form){
var URL = document.form.site.options[document.form.site.selectedIndex].value;
window.location.href = URL;
}
// End -->
</SCRIPT>

<center>
<form name="form">
<select name="site" size=1 onChange="javascript:formHandler()">
<option value="">Choose Paragraph

<option value="#Paragraph1"> Paragraph 1 </option>
<option value="#Paragraph2"> Paragraph 2 </option>
<option value="#Paragraph3"> Paragraph 3 </option>

</select>
</form>
</center>

 

Further down on my page here is my anchors.  They are of course seperated with text in between them:

 

<a name="Paragraph1">Paragraph 1</a>
<a name="Paragraph2">Paragraph 2</a>
<a name="Paragraph3">Paragraph 3</a>

 

Someone told me I might need to change this line:

window.location.href = URL;

 

with this:

window.location = window.location + URL;

 

It stil doesn't work

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.