Credit Counseling - Cheap Gas - Loan - Loans
Choosing where to submit form data [Archive] - Threeboy Forums

PDA

View Full Version : Choosing where to submit form data


Jamblo
09-22-2003, 07:06 AM
Say I had a form on a web site that, when you typed in a word and hit submit, a google window with search results appeared. An example of this can be found on threeboy's /start/ page:

[code:1]<form name="google" action="http://www.google.ca/search">
<input maxLength="256" name="q" size="20"><input type="submit" value="Internet"></form>[/code:1]

Now, say I wanted to add some radio buttons to this form where I could choose which search engine I wanted to use. For examples sake I'd like to use a dictionary too, also found on threeboy's /start/ page:

[code:1]<form name="dictionary" action="http://www.dictionary.com/search">
<input maxLength="256" name="q" size="20"><input type="submit" value="Dictionary"></form>[/code:1]

So, in theory, the radio buttons would have the action="http://www..." incorporated into it, ready for the user to select they're desired search engine.

Does anyone know how the heck I'd do this?

Thanks in advance.

zubaz
09-22-2003, 08:30 AM
I know that at least with PHP you'd have to parse the submitted data real quick before doing anything and then have a redirect or just have your page load up the results. Chances are that would go unnoticed, but I think that's more trouble than it's worth and what you're looking for is done with javascript. I've coded like 2 javascript things ever, so I dont' precisely know how to do it, but I'm pretty damn near positive that it's possible, and probably not that hard. Look through some javascript sites maybe? There's got to be a way to tie the action to the variable defined by the radio buttons.

This isn't what you're looking for, but by changing some stuff you should be able to make it that.
http://javascript.internet.com/forms/search-box.html

09-22-2003, 11:45 PM
Are you totally comitted to the radio button idea? You could do it a lot easier if you just attached the link to a standard submit button, one for each of the search engines.

Xelopheris
09-23-2003, 04:30 AM
With PHP, you would have to have it go to one page, and then <META> refresh to another.

inigoesdr
09-23-2003, 08:33 PM
Why use the META refresh? Why not just use the header(); function after you parse the data and build the URL?

Jamblo
09-24-2003, 02:23 AM
Sorry, I should have said, I can't use PHP for this particular search.

@ zubaz: I searched t' net for ages trying to find the right script but never found what I was looking for, this thread was a last resort! Thanks for link though =]

@ smitty: could you explain how I'd do that? I think the main problem here is the "action="http://www.google.ca/search" part of the form tag. This snippet would need to go in the button's code, I assume, but when I tried this, it failed to work!

Thanks for other comments.

Anyone else got any ideas? :?

09-24-2003, 04:39 AM
[code:1]
<form action="http://www.google.com/search" name=f>
<input maxlength=256 size=25 name=q value="">
<input type=image src=MY_BUTTON.gif border=0 align="Submit" alt="Submit Search" name=btnG>
</form>
[/code:1]

This puts a google on your site with the button image specified, all you need to do is substitute or insert whatever graphics you'd want to show and find the criteria to pass to the various search engines in the form action= portion. I've never tried to do this with radio buttons but, this works.

Mike

drake
09-26-2003, 10:01 AM
He already said that he wants radio buttons and can do it the way you just did it but he doesn't want that.

The only way to do it without Server Side scripting is with VBScript or JScript.

Check out www.astalavista.com's search engines. They have a drop down to select the search engine and its all powered by JS.

09-26-2003, 02:48 PM
Um, I don't see where he said that. <Shrug> I see where he said he wanted to use a radio button but then when I said if you're not totally comitted to the radio button you could do it with regular submission buttons and he asked how to do that so that's how.

Xelopheris
09-26-2003, 04:32 PM
If someone wants a radio button, it means he doesn't want 4 fields.

The easiest way is probably JavaScript

09-26-2003, 10:56 PM
I really recommend you read the entire thread. You've missed a chunk that explains why I gave him that bit of code and explanation. He asked me to, okay? Now go get some sleep. :P

zubaz
09-27-2003, 11:09 PM
actually he asked how to attach the action data to a button - which you did not explain, so stop telling people that can read to go to sleep.

09-28-2003, 03:44 AM
I didn't? Interesting, it looks to me like I did.

Though it's not a radio button, that's not what he asked me (specifically me, not the original first post).

And if I may also quote the following...

his post was brought to you by A Lack of Sleep

That's what the 'go get some sleep' was about. Damn, stop taking things I say out of context, that's so rude and ignorant.

zubaz
09-28-2003, 10:09 AM
@ smitty: could you explain how I'd do that? I think the main problem here is the "action="http://www.google.ca/search" part of the form tag. This snippet would need to go in the button's code, I assume, but when I tried this, it failed to work!
[code:1]
<form action="http://www.google.com/search" name=f>
<input maxlength=256 size=25 name=q value="">
<input type=image src=MY_BUTTON.gif border=0 align="Submit" alt="Submit Search" name=btnG>
</form>
[/code:1]

Your button's code does not have any action data in it. And if you'll notice the very first post of the topic, Jamblo had already posted an equivalent to your code. You may call me rude and ignorant again if you wish, but you might want to brush up on your reading first.

chesh
09-28-2003, 11:11 AM
Damn, stop taking things I say out of context, that's so rude and ignorant.

It may be time to recognize that people can her inflection in your voice in forums. Zubaz isn't the first (or second) to misunderstand what you say for an insult when you're just being facetious. It's not ignorant, it's just a misunderstanding. Taking things out of context is easy in "written word" so it's really neither rude nor ignorant.

09-28-2003, 06:50 PM
Ok, look.

* <-This is your brain.

@ <-This is your brain on drugs.

_ <-This is your brain after it's been run over by a 50 ton steamroller.

Any questions?

zubaz
09-28-2003, 10:48 PM
I realize this is not a radio button.
[code:1]<form name="zubazsearchomatic" onsubmit="javascript: window.open(this.u.options[this.u.selectedIndex].v alue + this.query.value);">

<select name="u" style=""><option value="http://www.google.com/search?q=">Google</option>
<option value="http://www.dictionary.com/cgi-bin/dict.pl?db=*&term=">Dictionary</option>
</select>

<input name="query" size="30" maxlength="35">
<input type="submit" value="Search" name="submit">

</form>[/code:1]
After much searching, I found that radio buttons are SATAN in javascript. But a pull down select box isn't so bad is it? But anyway, this works, just make sure the new options you add in have the correct variable name for their query (ie Google uses "q" and dictionary.com uses "term"). you'll have to look for the other engines' variable names.

Liquor_Riss
09-29-2003, 08:03 AM
Any questions?
Whats your point? :?

Jamblo
09-30-2003, 12:27 AM
Excellent Zubaz, thank you very much.

Thanks for everyone's input :D

10-08-2003, 03:35 AM
Riss Rote

Whats your point?


Point? No point...

LOOK! A naked girl!

SileNceR
10-09-2003, 06:24 AM
No wonder you've got so many posts.

inigoesdr
10-09-2003, 11:14 AM
haha.

10-10-2003, 03:06 AM
Hey man, less than you've got But heck, your name is Silencer, you're supposed to be quiet... So...

BE QUIET!

Liquor_Riss
10-10-2003, 03:14 AM
He did join more than a year before you ;)

10-10-2003, 03:23 AM
Yes, but, his name is Silencer, so how'd he get 400+ posts? Not very silent if you ask me. :)

Now, if I haven't gone past 1000 posts in a year, that'll be a surprise. :)

Liquor_Riss
10-10-2003, 03:28 AM
*Sighs and shakes head*
For all your 38 years, you're not so clever eh?

Silencer - Maybe, just maybe, this means that he silences other people, how I'm not so sure.

If he was called Silence on the other hand, then you might have a point......but meh.

10-10-2003, 06:53 AM
Must be a language problem. American funny versus English funny, I dunno but, I thought it was kind of obvious I was joking. But oh well, okay, we'll play it that way.

Yes, I was 100% serious, I believed that since his name was silencer he should not talk. I thought he was a mime, I figured he'd have to use some electronic equivellant of sign language to communicate here. Yep, that's it, that's what I thought.

I won't even get into what I think your handle may mean. Sounds like some kind of cordial produced from snake byproducts. But I digress. MEH Back atcha!

Liquor_Riss
10-10-2003, 07:30 AM
MEH? Whats that meant to mean? :?

Meh, probably some old man thing.

inigoesdr
10-10-2003, 11:45 AM
Licorice. Smitty needs help.

Liquor_Riss
10-10-2003, 11:53 AM
Smitty needs help.
Word up, doc.

10-10-2003, 11:41 PM
Keep it up you guys, I'll start calling you all "young fellas" or "kids", or the ever popular "young whippersnappers".

Liquor_Riss
10-11-2003, 03:59 AM
I don't mind, I call people whippersnappers all the time :P

10-11-2003, 06:58 AM
I have absolutly nothing interesting to say in response to that. So...

...A suffusion of yellow.

Liquor_Riss
10-11-2003, 07:56 AM
I have absolutly nothing interesting to say in response to that.
Business as usual eh? ;)

inigoesdr
10-11-2003, 12:18 PM
hahaha. :D

10-12-2003, 12:36 AM
Be quiet you young whippersnappers!

SileNceR
10-13-2003, 04:09 AM
if you've got nothing to say, then why procede to fill up a perfectly good thread with mindless crap?

10-14-2003, 10:11 AM
Exqueeze me? Show me the place on here where the mindless crap DOESN'T go? I wasn't aware this site was about finding a cure for cancer or rocket science. Seems to me it's all mindless crap. So pardon me for adding my own to the mix. Yeesh, everybody's a fucking critic!

zubaz
10-14-2003, 02:20 PM
The guy asked a question, we answered it. That's called communication. Everything following that was the crap.

10-15-2003, 09:10 AM
Thanks for adding your crap. I love people who think their shit don't stink. Blow!

zubaz
10-15-2003, 09:40 AM
**banned** **closed**