Click to See Complete Forum and Search --> : Radio Buttons
bda_rock
02-22-2003, 03:46 PM
Hello, I am trying to write a page that will select another page depending on the radio buttons I check. The difficult part is that I have 3 different sets of radio button with 12 selections in each. The options are from 01 to 12. As I said the page is dependant on the 3 selections I make. If I select radio1 button 05, radio2 button 11 and radio3 button 05 I need to select page 051105.html Can anyone help
Zach Elfers
02-22-2003, 04:03 PM
In the <head> section:
<script type="text/JavaScript">
<!--
function go() {
self.location.href = document.formName.radioSet1.value + document.formName.radioSet2.value + document.formName.radioSet3.value + ".html";
}
//-->
</script>
To call the script:
<input type="button" value="Go" onclick="go();">
bda_rock
02-24-2003, 05:42 AM
I am getting the following error.
Error: 'document.formName.radioSet1' is null or not an object
Code 0
Here is my page
<html>
<head>
<script type="text/JavaScript">
<!--
function go() {
self.location.href = document.formName.radioSet1.value + document.formName.radioSet2.value + document.formName.radioSet3.value + ".html";
}
//-->
</script>
<title>New Page 1</title>
</head>
<body>
<p> </p>
<form>
<p><input type="radio" value="01" name="radioSet1"> R1-01<br>
<input type="radio" name="radioSet1" value="02"> R1-02</p>
<p><input type="radio" name="radioSet2" value="01"> R2-01<br>
<input type="radio" name="radioSet2" value="V1"> R2-02</p>
<p><input type="radio" name="radioSet3" value="01"> R3-01<br>
<input type="radio" name="radioSet3" value="02"> R3-02</p>
<p> </p>
<p><input type="button" value="Go" onclick="go();"></p>
</form>
</body>
</html>
bda_rock
02-24-2003, 08:25 AM
No.
Before this I just did basic webpages, thought this would be an easy way to select a new page... Then came Javascript.... Anything you can do to help get this page going would be appreciated.
bda_rock
02-25-2003, 05:14 AM
Beautiful. Thanks you very much.
khaki
02-25-2003, 09:26 AM
Yes Dave.. that is beautiful (and I'm glad that you posted to this before I did, 'cause
my hack solution would have caused me severe embarrassment for ages!).
So anyway, kind of along the same idea - and yet not at all (huh?) - how do you
"add" (not concatenate) the values?
(and obviously, leading zeros would not be used in the values)
Mostly I'm looking to add the values that would be found in multiple text boxes
(not the values assigned to buttons, but both ways would be good to know).
I'm sure that I did it in the past (back when I was a REALLY embarrassing hack),
but I've searched my archived files for about 20 minutes now, and aside from some
really good laughs at some really bad code (wow I've come a long way), I haven't
been able to find it.
I've also been hammering at my many javascript books, but the geniuses who
wrote them seem to think that I need to know more about Euler's constant, logarithms,
and square roots than 2+2 (lol).
Seems simple enough (too simple?), but I'm a VB'er ("+" means "plus" and "&" means "and")
so I'm spinning in Javascript circles on this one.
(gotta love this forum... one thing leads to another)
currently dizzy...
k
I think what you are looking for is going to be something along these lines:
<script language="javascript" type="text/javascript">
one = document.formname.input1name.value;
two = document.formname.input2name.value;
three = Number(one) + Number(two); // turn values into numbers
alert (three);
</script>
Oops... :( Your right, of course...Edited to fix. Hate it when I do dumb things like that... :rolleyes: