Wrox Home  
Search P2P Archive for: Go

  Return to Index  

html_code_clinic thread: Find out values for a radio button


Message #1 by "Bharat Saboo" <bharatsaboo@h...> on Mon, 25 Feb 2002 12:31:18 +0530
Hi Bharat,

The way to do this is with JavaScript. I don't know how much you know, so 
I will try and keep it simple.

Basically when you want to check the values, call a function in JavaScript 
that checks each element in the form.

For checkboxes use:
 document.forms[0].<elementName>.checked;
replacing <elementName> with the name attribute of the element you are 
checking e.g. for:
 <input type="checkbox" name="chk">
you would write:
 isChecked = document.forms[0].chk.checked;

For radio buttons you have to say which button in the group you are 
checking, as they all have the same name.
In JavaScript you have to specify the index of the button, the first one 
being index 0, the second index 1 etc.
So for the first radio button in radGroup, you would write:
 isChecked = document.forms[0].radGroup[0].checked;

If this is too confusing, have a look at:
  http://www.dcs.shef.ac.uk/~u1pc/formValues.html
It might help a bit.

Regards

Philip
-------------------------
dhtml_phil@p...

  Return to Index