|
-
Mar 18th, 2008, 01:56 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] Multiplesearch engines...
I'm creating a home page that will have 4-5 submit buttons, but with only 1 textbox to search with.
Each submit button will lead to a different search engine (Google, Youtube, Live, etc etc). But there will only be one text box to type something into.
The google search works like:
Code:
<form id="form1" name="frmsearchbox" method="get" action="http://www.google.com/search">
<input type="text" name="q" style="width:40%"/>
<input type="submit" value="Search Google" />
</form>
Notice that the textbox name has to be "q". Otherwise it will not work. Now the youtube textbox has to be named "search_query".
I wish to only have 1 textbox to type into, but 5 buttons. The only way i can think of doing this is to have 5 hidden textboxes (With the correct names) and have them all filled up with the same data when a button is pressed, and then send it off to the search engine.
If someone knows how this would be done (No doubt java will be needed, hence why its posted here), it would be much appreciated. I don't even know what to search for concerning this, so i had to ask directly.
Edit:
Actually, it would be useful too if i juts had 1 combobox & 1 submit button, but what ever you can provide =).
Last edited by Slyke; Mar 18th, 2008 at 02:07 AM.
-
Mar 18th, 2008, 06:32 AM
#2
Re: Multiplesearch engines...
You can do it either way. And you mean JavaScript rather than Java.
Rather than using a form, use the onClick for the buttons.
This is just an example, you will need to refine it
Code:
<input type="text" value="" name="query" id="query" />
<input type="button" value="Google" id="Google" name="Google" onClick="doSearch('Google');" />
<input type="button" value="YouTube" id="YouTube" name="YouTube" onClick="doSearch('YouTube');" />
<script type="text/JavaScript">
function doSearch(searchEngine)
{
switch(searchEngine)
{
case "Google":
document.location.href='http://www.google.com/search?q=' + document.getElementById('query').value;
break;
case "YouTube":
document.location.href='http://www.youtube.com/results?search_query=' + document.getElementById('query').value;
break;
}
}
</script>
You could also use a <select> box and look at the selected option, do a switch() on that value.
-
Mar 18th, 2008, 06:40 AM
#3
Thread Starter
Fanatic Member
Re: Multiplesearch engines...
That's awesome =D.
I'll do that, and if i have any troubles i'll post it here, if not then i'll close the thread =).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|