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

Go to Anchor Function

Status
Not open for further replies.

JBorges

Technical User
Jan 12, 2009
57
0
0
DK
Hi!

I have this code below that let's me type in a number that goes to the requested anchor tag. All my anchor tags in my html file are numbers.

<input type="text" onchange="window.location ='#' + this.value;" />

I would like to make this a function. I tried the following but it doesn't work:

<script>
function go() {
window.location ='#' + this.value;
}
</script>

<body style="font-size: 14px;">

<input type="text" onchange="go();" />

Can anyone help me?
--Philip
 
Thanks. I'll post it there. Probably a better place to post it.
 
Your function doesn't know what "this" is. As "this" would be itself.

Pass the ID of the textbox to it instead.

Code:
onChange="myfunction(this);"


...


function myfunction(mybox){
window.location ='#' + mybox.value;

}

You may also want to rename your function as go is a Javascript function already, and it may cause problems


For any further JS questions, you should ask here: forum216


----------------------------------
Phil AKA Vacunita
----------------------------------
Ignorance is not necessarily Bliss, case in point:
Unknown has caused an Unknown Error on Unknown and must be shutdown to prevent damage to Unknown.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top