/    Sign up×
Community /Pin to ProfileBookmark

multiple anchors

Hello all,

I’m developing in php but my problem is more of a html/javascript one.

I have an output page with many unknown anchors in it (about a 1000)
What I need is to make easy link to those anchors which are numbers.
For example if a user wants to see anchor number 121 he’ll just fill a text field with that number and click go , and that should bring him to anchor 121 in the page.
I tried this code:

<form name=anchor><tr><td>Go to log number: <input type=text size=1 name=ancNo><A HREF=”JavaScript: location.href=#anchor.ancNo.value;”>Go</A> </td></form>

with no success.
any ideas?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@KorMar 30.2004 — eerr... The correct syntax book says that names must begin with a letter, not a number or another special character... Some servers woun't like otherwise...

So, I advise you to name the anchors:

<a name="a1"></a>

<a name="a2"></a>

<a name="a3"></a>

....

<a name="a121"></a>

Now, try this:

[code=php]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<script>
function goAnchor(d){
location.href='#a'+d.form.inp.value;
}
</script>
</head>
<body>
<form>
<input name="inp" type="text"><input type="button" value="Go" onclick="goAnchor(this)"><br>
</form>
<a name="a1"></a>
</body>
</html>
[/code]
×

Success!

Help @yaron spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 6.16,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @nearjob,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...