Solved

More troubles with dual search input forms

Posted on 2002-05-15
9
177 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
 
LVL 23

Expert Comment

by:b1xml2
ID: 7013370
and just to add that leveret posted the answer first =))
0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now