Solved

More troubles with dual search input forms

Posted on 2002-05-15
9
204 Views
Last Modified: 2010-04-09
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?
0
Comment
Question by:Decimal
  • 3
  • 3
  • 2
  • +1
9 Comments
 
LVL 12

Expert Comment

by:lexxwern
ID: 7012979
<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
0
 
LVL 2

Accepted Solution

by:
Marianne earned 200 total points
ID: 7013301
<form method="get" action="http://www.google.com/search">
<input type="hidden" name=t>
<input type="text" name="q" size="60" maxlength="255"></font></td></tr><tr><td>

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

This way it will Google-search without using javascript at all.
0
 
LVL 23

Expert Comment

by:b1xml2
ID: 7013368
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>
0
Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 23

Expert Comment

by:b1xml2
ID: 7013370
and just to add that leveret posted the answer first =))
0
 

Author Comment

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

Author Comment

by:Decimal
ID: 7014052
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.
0
 
LVL 2

Expert Comment

by:Marianne
ID: 7014098
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 :-\
0
 

Author Comment

by:Decimal
ID: 7014134
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.
0
 
LVL 2

Expert Comment

by:Marianne
ID: 7015014
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 ;)
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question