Solved

More troubles with dual search input forms

Posted on 2002-05-15
9
212 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Open dialog with server side controls in it 3 48
message Alert on an empty search 10 30
I'm a Human captcha checkbox 13 43
Send form to asp server side 6 28
This article explains how to prepare an HTML email signature template file containing dynamic placeholders for users' Azure AD data. Furthermore, it explains how to use this file to remotely set up a department-wide email signature policy in Office …
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
In this tutorial viewers will learn how to style elements, such a divs, with a "drop shadow" effect using the CSS box-shadow property Start with a normal styled element, such as a div.: In the element's style, type the box shadow property: "box-shad…
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 …

730 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