PDA

View Full Version : Question about how to receive value from sets of radio buttons


hat7159
10-16-2002, 01:29 AM
I am looking for a sure way to determine the value of sets of radio buttons on a form. This would be similar to a quiz, with a question and five possible answers. How would I transfer the someone's answer to a question in a javascript variable (e.g. "q1"). I am not interested in score the answer (comparing it to another preset "correct" answer), but merely recording the answer in a javascript variable. Any ideas?

chrismiceli
10-16-2002, 03:05 AM
you can put this in a function or whatever but here is the syntax

variable = document.formname.radiobuttonname[whatevernumberitis].value;

whammy
10-16-2002, 03:34 AM
chris is right, but if you have multiple radio buttons with the same name you have to LOOP through them and determine which one is checked (if any).

If you do a search for "radio buttons" on the forum you should find a multitude of examples illustrating this concept. :D