![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
|
Best to use: Or: document.forms.myform.elements.owned_business[0].checked |
#2
| |||
| |||
|
|
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" 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, 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? Thanks, Ron |
#3
| |||
| |||
|
Thanks ![]() Ron |
#4
| |||
| |||
|
|
Ron Eggler 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" 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, 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? Thanks, Ron Try alert(document.forms['myform']['owned_business'][0].checked); |
#5
| |||
| |||
|
|
Best to use: document.forms['myform'].elements['owned_business'][0].checked Or: document.forms.myform.elements.owned_business[0].checked |
#6
| |||
| |||
|
|
David Mark said: Best to use: document.forms['myform'].elements['owned_business'][0].checked Or: document.forms.myform.elements.owned_business[0].checked Why? |
#7
| |||
| |||
|
|
David Mark said: Best to use: document.forms['myform'].elements['owned_business'][0].checked Or: document.forms.myform.elements.owned_business[0].checked Why? |
#8
| |||
| |||
|
|
On Jan 3, 7:45 pm, Anthony Levensalor <killf... (AT) mypetprogrammer (DOT) com wrote: David Mark said: Best to use: document.forms['myform'].elements['owned_business'][0].checked Or: document.forms.myform.elements.owned_business[0].checked Why? Because that is the standard and most compatible syntax. |
#9
| |||||
| |||||
|
|
On 1鏈4鏃, 涓婂崍9鏃29鍒, David Mark <dmark.cins... (AT) gmail (DOT) com> wrote: [...] Anthony Levensalor [...] wrote: David Mark said: Best to use: document.forms['myform'].elements['owned_business'][0].checked Or: document.forms.myform.elements.owned_business[0].checked Why? Because that is the standard and most compatible syntax. There is the best use |
|
input type="radio" name="r" value = "1" id="radio1" / |
|
First ,marked the element by "id" property Then use this expression to find it script language="javascript" |
|
var myradio = document.getElementById("radio1"); |
|
alert(myradio.checked); |
#10
| |||
| |||
|
|
Please attain a minimum amount of basic knowledge before you post more of your "recommendations". |
![]() |
| Thread Tools | |
| Display Modes | |
| |