Setting focus to search page input field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dave Rado

    Setting focus to search page input field

    Hi

    I have been the following code by Freefind to use on my search page:

    <form action="http://search.freefind .com/find.html" method="get"
    accept-charset="utf-8" target="_self">
    <input type="hidden" name="id" value="[unique id for my website]">
    <input type="hidden" name="pageid" value="r">
    <input type="hidden" name="mode" value="all">
    <input type="hidden" name="n" value="0">
    <input type="hidden" name="_charset_ " value="">
    <input type="hidden" name="bcd" value="&#247;">
    <input type="text" name="query" size="15">
    <input type="submit" value=" Find "></form>

    It works great, but want to set the focus to the search textbox when
    the page loads so that the user can start typing, using <body onload
    ="document.getE lementById('Scr ollableContent' ).focus()">, but I can't
    see any id for the search textbox in the code I've been given.

    How can I set the focus to the search textbox when the page loads?

    Dave
  • Dave Rado

    #2
    Re: Setting focus to search page input field

    Sorry typo in my previous post, I meant to write:

    It works great, but I want to set the focus to the search textbox when
    the page loads so that the user can start typing straight away, using
    <body onload="documen t.getElementByI d('[id of textbox]').focus()">

    Dave

    Comment

    • Joost Diepenmaat

      #3
      Re: Setting focus to search page input field

      Dave Rado <dave.rado@dsl. pipex.comwrites :
      Hi
      >
      I have been the following code by Freefind to use on my search page:
      >
      <form action="http://search.freefind .com/find.html" method="get"
      accept-charset="utf-8" target="_self">
      <input type="hidden" name="id" value="[unique id for my website]">
      <input type="hidden" name="pageid" value="r">
      <input type="hidden" name="mode" value="all">
      <input type="hidden" name="n" value="0">
      <input type="hidden" name="_charset_ " value="">
      <input type="hidden" name="bcd" value="&#247;">
      <input type="text" name="query" size="15">
      <input type="submit" value=" Find "></form>
      >
      It works great, but want to set the focus to the search textbox when
      the page loads so that the user can start typing, using <body onload
      ="document.getE lementById('Scr ollableContent' ).focus()">, but I can't
      see any id for the search textbox in the code I've been given.
      Just add one:

      <input type="text" name="query" id="ScrollableC ontent" size="15">

      Though you should probably use a more meaningful ID.

      --
      Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

      Comment

      • Dave Rado

        #4
        Re: Setting focus to search page input field

        I've worked out the answer - I just needed to change to form's code
        from:

        <input type="text" name="query" size="15">

        to <input type="text" name="query" id="query" size="15">

        .... and then use the id "query" in my onload statement.

        Sorry about that.

        Dave

        Comment

        • Dave Rado

          #5
          Re: Setting focus to search page input field

          On Apr 15, 12:22 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
          Though you should probably use a more meaningful ID.
          Yes, that was a typo, sorry (see my earlier replies to my original
          post, which I was typing while you were typing your reply).

          Thanks, and apologies for posting before I'd put enough thought into
          trying to solve it myself.

          Dave

          Comment

          • Joost Diepenmaat

            #6
            Re: Setting focus to search page input field

            Dave Rado <dave.rado@dsl. pipex.comwrites :
            On Apr 15, 12:22 am, Joost Diepenmaat <jo...@zeekat.n lwrote:
            >
            >Though you should probably use a more meaningful ID.
            >
            Yes, that was a typo, sorry (see my earlier replies to my original
            post, which I was typing while you were typing your reply).
            >
            Thanks, and apologies for posting before I'd put enough thought into
            trying to solve it myself.
            No problem. Sometimes it just works best to step back a bit to think
            things over.

            Cheers,
            Joost.

            --
            Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/

            Comment

            Working...