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

Popular posts from this blog

matlab - Deleting rows with specific rules -

jquery - How would i go about shortening this code? And to cancel the previous click on click of new section? -