473,385 Members | 1,925 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Scrolling to an internal Link

Hello,

I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.

i.e

A piece of information

<span name="gohere">
hello world
</span>

I then have an input field and a button. If "gohere" is entered and
the button clicked I want the page to scroll to the span above (like
an internal link) Is this possible??

Jun 18 '07 #1
4 4600
Iain Adams wrote:
Hello,

I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.

i.e

A piece of information

<span name="gohere">
hello world
</span>

I then have an input field and a button. If "gohere" is entered and
the button clicked I want the page to scroll to the span above (like
an internal link) Is this possible??
Hrmm... probably yes. However, wouldn't using named anchors be much
more suitable?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Jun 18 '07 #2
On 18 Jun, 14:26, -Lost <maventheextrawo...@techie.comwrote:
Iain Adams wrote:
Hello,
I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.
i.e
A piece of information
<span name="gohere">
hello world
</span>
I then have an input field and a button. If "gohere" is entered and
the button clicked I want the page to scroll to the span above (like
an internal link) Is this possible??

Hrmm... probably yes. However, wouldn't using named anchors be much
more suitable?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.
Well yeah named anchors would be good. But Say I have thousands of
places I want to jump to. Then I wud have to have thousands of links.
<a href="#gohere">. This probaly wouldnt be much good. What i want is
a named anchor but without the actual anchor. haha. Basically i want
to replicate what the named anchor does but when a button is clicked
and using the name given in a text field. Do you know how to do this?

Jun 18 '07 #3
Iain Adams wrote:
On 18 Jun, 14:26, -Lost <maventheextrawo...@techie.comwrote:
>Iain Adams wrote:
>>Hello,
I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.
i.e
A piece of information
<span name="gohere">
hello world
</span>
I then have an input field and a button. If "gohere" is entered and
the button clicked I want the page to scroll to the span above (like
an internal link) Is this possible??
Hrmm... probably yes. However, wouldn't using named anchors be much
more suitable?

--
-Lost
Remove the extra words to reply by e-mail. Don't e-mail me. I am
kidding. No I am not.

Well yeah named anchors would be good. But Say I have thousands of
places I want to jump to. Then I wud have to have thousands of links.
<a href="#gohere">. This probaly wouldnt be much good. What i want is
a named anchor but without the actual anchor. haha. Basically i want
to replicate what the named anchor does but when a button is clicked
and using the name given in a text field. Do you know how to do this?
what about the same old named anchors and button with
onclick="location.href='#'+document.getElementById ('text_field').value" ?

see, if you want to scroll page to some span you first need to find that
span according to what user typed in text field, then you need to
calculate offset of that span and then scroll there (something like
"document.scrollTop=there", not sure if correct syntax, check it out).
Jun 18 '07 #4
On Jun 18, 5:19 am, Iain Adams <aca04...@shef.ac.ukwrote:
Hello,

I have a page with a text field. When something is typed into the text
field and a button is clicked I want the page to scroll to the
relevant place on the page that has the value of the text field as its
name.

var elem=document.getElementsByName(textFieldValue)
if(elem)elem.scrollIntoView()

Jun 18 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: PythonistL | last post by:
I am a newbie with Javascript. I have this simple script for scrolling text <HTML> <HEAD> <TITLE>Scrolling Message Script</TITLE> <SCRIPT language="JavaScript"><!-- var msg = 'My scrolling...
0
by: stan | last post by:
I have internal links/jumps within divs. The divs have vertical scrolling. When a link is clicked, both the space within the div as well as the entire page vertically scroll. I would like to...
3
by: Chamnap | last post by:
Hello everybody, I have one problem. I want to do something after the user finished scrolling. The scroll event fires whenever the user is scrolling. I don't want this actually. Does anyone has...
11
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I know I sound like a one-note Johnny on this but I'm still looking for a solution. I need to display characters coming in from a serial port or a socket. I also need to be able to type...
1
by: asearle | last post by:
Dear all, I have been working to implement a scrolling table into an xml / xsl interface and so far have managed to put together an acceptable version using <thead> and <tbody> syntax. Indeed for...
4
by: rosta | last post by:
Hi, I found following problem in FF 3.0.9 (it looks it is FF problem only). See few lines of code below: <html> <head> <title>TEST</title> <script type="text/javascript"> ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.