View Full Version : How to read values from Radio Buttons

08-07-2002, 10:32 PM

I'm new to java.

I'm trying to submit a URL from a Form, the user has to choose between 3 different URLs that are displayed as radio buttons.
So the user can only choose one of them.

After that I'd like to pass the selected button's value to a function which will read the value and append that string to another string to form a complete URL.

I'd appreciate it if any one could help



08-07-2002, 10:38 PM
Well, if the form's submit method is GET then you don't need to use a function. The value for the radio button object will already appear in the URL as part of the querystring.

08-07-2002, 10:45 PM

it is actually a GET, but I append the 2 strings before submitting the form, so I send the complete URL like this

top.location.href = './'+R1+D2+'.htm';

where R1 is the value of the radio button, and D2 is the rest of the URL

how do I call the radio object?, thatīs whatīs still unclear to me.
I don't know how to assign the button's value to the R1 variable.

I know I must look like a complete idiot to you. I'm really ignoratn at this.

08-07-2002, 10:52 PM
var R1 = document.forms[0].radio1.value;

<input type="radio" value="choice1" name="radio1" />
<input type="radio" value="choice2" name="radio1" />
<input type="radio" value="choice3" name="radio1" />

08-07-2002, 11:04 PM
That did it!!

thank you so much.