Ron said:
Hi,
I would like to run a jvascript, checking if the radio button
is checked. My radio button looks like:
<input type="radio" name="owned_business" value="yes">
That is way to little context to get any sensible answer to the
question. Radio buttons are expected to be in sets (all with the same
name) and operate in a way that guarantees that at least one of them is
always checked. An single input element that is expected to have one of
two boolean states is best represented with a 'checkbox' element.
and i would like to check it with this:
alert (document.myform.owned_business.checked);
if (document.myform.owned_business.checked == false)
but alert returns me "undefined" and i don't understand why,
If you have more than one like-named radio button element in a form then
referencing them by name will give you an object that is a collection of
all of the like-named radio buttons. But then there is no sensible way
in which you can talk of "checking if _the_ radio button is checked".
my form name is "myform" and the name of the radio is
"owned_business" so i'm not seeing where i go wrong.
Can anyone help me?
Most of the couple of hundred ways in which you could "go wrong" here
would not result in "undefined" being alerted, but experience tells me
that an OP reporting something is not a valid indicator of it actually
being the case. (Demonstrations are the only convincing evidence that
something is the case, and demonstrations also provide full context for
whatever it is that they demonstrate).
See:-
<URL:
http://jibbering.com/faq/faq_notes/form_access.html >
Richard.