Passing Variables from Radio Button Choice to HREF Command - Help!
I am trying to create a scenario on a website that I am building, in which the user makes a selection from two radio button choices and then clicks the graphic button below the choices to go to the address. The button I am using is not a form button, but one that is a graphic I am putting there with a link. My question is, how do I do this? I do not know how to pass a variable choice and load an <a href ....> link with it. The variable would have to be loaded from the choice that is made by the user when selecting one of the two radio button choices.
Can anybody help me? I do not know if this can be done in Java , CGI or any other. I have not seen any examples of it on the web and do not know if it can even be done. And - I am new to web programming.
Any help would be greatly appreciated!
JP Stones posted this at 04:13 — 18th October 1999.
They have: 2,390 posts
Joined: Nov 1998
I'm not sure what you mean but for an img equivalent of an input button use:
<input type="image" src="dir/img.gif" border="0">
JP
----------
[red]The Next Step in Website Development [/red] - http://www.what-next.com
The Webmaster Promotion and Resource Center
Ray posted this at 04:28 — 18th October 1999.
They have: 15 posts
Joined: Sep 1999
Thanks JP for your response!! It was helpful to know how to change the input button into an image.
To take it a bit further, when the user clicks on that input button, I want them to be able to go to a linked page - or an audio file, depending on which radio button they choose.
Is that possible?
Thanks again JP!
Anonymous posted this at 17:18 — 18th October 1999.
They have: 5,633 posts
Joined: Jan 1970
and here comes my CGI-solution:
put the button and the radios into a form and link it to this cgi script using method get:
#!/usr/bin/perl
$foo = $ENV{QUERY_STRING};
if ($foo = "button\=sound" ){print"Location: http://blah blah/sound.html"}
else {print"Location: http://blah blah/image.html"}
exit;
Federico, any backslashes missing?
later
patrick
Ray posted this at 18:00 — 18th October 1999.
They have: 15 posts
Joined: Sep 1999
Thanks Patrick for your help!! And JP - for telling me how to change the input button to my own graphic.
The help was very much appreciated!!
Ray
Anonymous posted this at 20:16 — 19th October 1999.
They have: 5,633 posts
Joined: Jan 1970
You can do this with JavaScript and it is really quite easy to implement.
INSERT BETWEEN <HEAD></HEAD> TAGS
function navigate() {
if (document.radioForm.selection[0].checked) {
window.location.href = "URL 1";
}
else {
window.location.href = "URL 2";
}
}
INSERT BETWEEN <BODY></BODY> TAGS
<form name="radioForm">
<input name="selection" type="radio"> OPTION 1
<input name="selection" type="radio"> OPTION 2
</form>
<a href="javascript:navigate()"><img src="URL"></a>
* Note i have not used
<input type="image" src="dir/img.gif" border="0"> as JP suggested. I think this way is easier.
I have answered many radio questions recently - are they back in fashion?
----------
[email protected]
http://go.to/hass
Ray posted this at 03:03 — 21st October 1999.
They have: 15 posts
Joined: Sep 1999
Thanks a million Lloyd!! I'll try the JavaScript you suggested!
As for radio buttons coming back into style - well, I like 'em cause from a marketing standpoint, they are more inviting to entice the user to interact with the page. They pull the user in to making a choice from several options - I think they can be very effective used under the right circumstances.
Thanks again!! I'll let you know how it works on my page!
Ray
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.