javascript - Radio button's behaviour -
im dom/javascript newbie trying basics right. i'm trying observe radio button's behavior on clicking it. heres code.
html
<script src="tmp.js"></script> <input type="radio" id="inp1" name="same" onclick="show();"/> <input type="radio" id="inp2" name="same" onclick="show();"/> js (tmp.js)
function show() { alert(document.getelementbyid("inp1").value + " " + document.getelementbyid("inp2").value); } what confuses me on running alert box says "on on" on clicking either of buttons. shouldn't "on off" or "off on"?
seems want checked property , have look:
function show() { alert( document.getelementbyid("inp1").checked + " " + document.getelementbyid("inp2").checked); } working example: http://jsfiddle.net/w7vgl/
Comments
Post a Comment