<input type="radio" value="0" name="type" checked="yes" />
<label>Type 0</label>
<input type="radio" value="1" name="type" />
<label>Type 1</label>
and js:
var type = this.type.value;
alert(type);
How to fix it ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
In what context does that JS code run? If
thisis the radio button in question thenthis.valuewill return the value.If your question is “How do I get the value of the currently selected radio button in the ‘type’ group?” then you may need to do something like this:
(It would be easier with
.querySelector()or.querySelectorAll(), but not all browsers support them.)