www.webdeveloper.com
Results 1 to 2 of 2

Thread: Create Single Text Box With Two Output Buttons

  1. #1
    Join Date
    May 2006
    Posts
    1

    Create Single Text Box With Two Output Buttons

    Hey guys, I'm trying to create a single text box which will output to two different actions.

    If you go here: http://stevenford.atspace.com/test.html you can see, I'm trying to combine Wikipedia and Google together, so one text input, then two search buttons. Anyway, I came across this bit of code, that seems to do it:

    <form method="get" action="http://www.google.ca/search">
    <input name="q" size="63">
    <input type="submit" value="Google Search" />
    <input type="submit" value="Image Search" onclick="this.form.action='http://images.google.com/images';" />
    </form>

    However, the problem is, for this to work, the input box must have the same name on both forms. Here it's "q", and that's fine, because both Google and image search have "q". However, Wikipedia has "search". Is it still possible to combine them together?

    Thanks a lot guys.

  2. #2
    Join Date
    Nov 2003
    Location
    Jerryville, Tejas
    Posts
    11,715
    <form method="get" action="http://www.google.ca/search" onsubmit="this.form.search.value = this.form.q.value; return true;">
    <input type="hidden" name="search">

    (Untested)
    "Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it." Brian W. Kernighan

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles