Iain Adams wrote:
> On 18 Jun, 14:26, -Lost <maventheextrawo...@techie.com> wrote:
>> 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).
|