Link to home
Start Free TrialLog in
Avatar of Decimal
Decimal

asked on

More troubles with dual search input forms

At http://www.dcross.net/dh/stardotgeek.htm I have a search box that uses two buttons. Based on information I recieved here earlier, this is how it works:

----
<form method="get">
<input type="hidden" name=q>
<input type="hidden" name=t>
<input type="text" name="search" size="60" maxlength="255"></font></td></tr><tr><td>

<input type="submit" value="&nbsp;Google Search&nbsp;" onclick="this.form.q.value = this.form.search.value; this.form.action
= 'http://www.google.com/search';">
<input type="submit" value="&nbsp;Teoma Search&nbsp;" onclick="this.form.t.value = this.form.search.value;this.form.action
= 'http://www.teoma.com/search.asp';">
----

The problem now is that when I type anything in the box and press enter, it simply reloads the page. I actually have to click one of the two search buttons to search, when really I want Google to be the "default" search. Any ideas how to get around this without using any form of javascript?
Avatar of lexxwern
lexxwern
Flag of Netherlands image

<input type="button" value="&nbsp;Teoma Search&nbsp;" onclick="this.form.t.value = this.form.search.value;this.form.action
= 'http://www.teoma.com/search.asp';">


see if this works
ASKER CERTIFIED SOLUTION
Avatar of Marianne
Marianne
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
since I was the author of that code, I invoke privilege and say that all you have to do is add to the action attribute of the form and leave the code as is:

<html>
<head>
<title>Search Submission</title>
</head>
<body>
<form method="get" action="http://www.google.com/search">
<input type="hidden" name="q">
<input type="hidden" name="t">
<input type="text" name="search" size="40" maxlength="255">
<input type="submit" value="Google Search" onclick="this.form.q.value = this.form.search.value; this.form.action = 'http://www.google.com/search';">
<input type="submit" value="Teoma Search" onclick="this.form.t.value = this.form.search.value;this.form.action = 'http://www.teoma.com/search.asp';">
</form>
</body>
</html>
and just to add that leveret posted the answer first =))
Avatar of Decimal
Decimal

ASKER

Problem solved! Now I've got another. B1xml2 wrote the original code, leveret posted the answer first. Who gets the answer points? :p
Avatar of Decimal

ASKER

Okay, looking over it again, leveret's code works better. B1xml2, your code takes it to google when I press "enter", but the page is blank after the logo at the top of the page.

Thanks, everyone.
There should be *absolutely* no difference of how the two variants of this code work. The thing that a page appears to be blank must have some other reason (probably blank field instead of some text in the form, or just bad connection)

The only difference is that my code is a bit shorter and thus probably more graceful. However it doesn't affect the results.

I don't really care much who will get the points, I don't eat points :) My opinion also is, that the rules of giving points in this forum takes away the pleasure of friendly conversation, making it formal and somewhat too commercial :-\
Avatar of Decimal

ASKER

I wasn't concerned about the points myself, just who to give the "official" credit to since that's a reasonable requirement to get an answer. But did you actually try putting both codes in seperate text files and seeing what happens when you run them in IE? I did, several times. Probably some small gramatical error that makes the page come up blank.
Just noticed. You are right, Decimal.

[ input type="text" name="search" ] should be replaced with [ input type="text" name="q" ] in the b1xml2's example. It will work quite as well then.

Good luck ;)