SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    London, UK
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript multiple search engine script help

    I have a javascript search engine i use on my website which i would like to change.

    You can see a scaled down version at http://www.hostcompanies.com/searchhelp.htm

    Problem is it only works when pressing the GO button.

    I would rather it also worked by pressing the enter / return key on the keyboard.

    Does anyone know how to alter this code to make it do that?

    I am not really very good very javascript and the orginal code was written by a friend.
    Add your web design / hosting companies to my directory - Web Hosting Directory
    Want to join our panel of experts? - Hosting Forums ( top right of forums -expert drop down box for more info ).

  2. #2
    SitePoint Member
    Join Date
    Sep 2002
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Put an onSubmit event on your form, and then put the same code to it as you did on the onClick event on the button. Like this:


    <form name="blah" onSubmit="alert('I pressed the enter button!')">

  3. #3
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    London, UK
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Well...

    All that does is to tell them to press the enter button which they allready did to get that message.

    What i want is that when they press the enter button on the keyboard it will perform the search ( so that they dont always have to click the go button ).
    Add your web design / hosting companies to my directory - Web Hosting Directory
    Want to join our panel of experts? - Hosting Forums ( top right of forums -expert drop down box for more info ).

  4. #4
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Code:
    input type="submit"
    ?

    instead of button?

  5. #5
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    London, UK
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ?

    I dont understand what you mean. Which part of the code do i change?

    Sorry my javascript is poor at best these days
    Add your web design / hosting companies to my directory - Web Hosting Directory
    Want to join our panel of experts? - Hosting Forums ( top right of forums -expert drop down box for more info ).

  6. #6
    + platinum's Avatar
    Join Date
    Jun 2001
    Location
    Adelaide, Australia
    Posts
    6,441
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    where you have:

    Code:
        </select>
        <input type=button value="Go!" onClick="window.location.href=document.searchform.site.options[document.searchform.site.selectedIndex].value+escape(document.searchform.keywords.value);" name="button">
        <br>
    change to:

    Code:
        </select>
        <input type=submit value="Go!" onClick="window.location.href=document.searchform.site.options[document.searchform.site.selectedIndex].value+escape(document.searchform.keywords.value);" name="button">
        <br>

  7. #7
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    London, UK
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    It did not work

    I allready tried that. I uploaded that version.
    http://www.hostcompanies.com/searchhelptest.htm

    As you can see nothing happens when you press enter.



    Perhaps the code needs to be re-written completely?
    Add your web design / hosting companies to my directory - Web Hosting Directory
    Want to join our panel of experts? - Hosting Forums ( top right of forums -expert drop down box for more info ).

  8. #8
    SitePoint Evangelist
    Join Date
    Jul 2001
    Location
    London, UK
    Posts
    475
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can anyone write this code for me?

    Does anyone know how to rewrite or fix the code so that its no longer necessary to click the GO button to make the search engine work?
    Add your web design / hosting companies to my directory - Web Hosting Directory
    Want to join our panel of experts? - Hosting Forums ( top right of forums -expert drop down box for more info ).


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •