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!

How to connect anchors to drop down list?

Status
Not open for further replies.

jlsmithhartfiel

Programmer
Jan 7, 2002
336
US
Try this, notice I changed the select options values

Code:
function doThis(obj) {
  // user already viewed one anchor so just replace the info
  if (location.hash != "") {
    location.hash = obj.options[obj.selectedIndex].value;
    loc = parent.location
  }
  // user hasn't selected an anchor yet so add the hash mark
  else {
    loc = parent.location + "#" + obj.options[obj.selectedIndex].value;
  }
  parent.location = loc;
}

<select name=&quot;select1&quot; size=&quot;140&quot; length=&quot;3&quot; onchange=&quot;doThis(this)&quot;>
<option VALUE=&quot;anchor1&quot; SELECTED>Choice1
<option VALUE=&quot;anchor2&quot; SELECTED>Choice2
<option VALUE=&quot;anchor3&quot; SELECTED>Choice3
</select>
Jessica [ponytails2]
 
Actually (never worked with location.hash before) but this is much simpler:
Code:
function doThis(obj) {
  location.hash = obj.options[obj.selectedIndex].value;
  parent.location.reload();
}
Jessica [ponytails2]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top