internet explorer - Selecting an html radio button dynamically through javascript does not work in IE -
i want select radio button javascript. using simple html file test issue. code below works correctly on firefox , chrome, not work in ie (no version works). know why supplied code not work on ie, , how select radio button in ie?
<html> <head> <script type="text/javascript"> function chooseone() { var randomchoice = math.round(math.random() * 2); if(randomchoice == 0) { document.getelementbyid("test0").checked = true; } else if (randomchoice == 1) { document.getelementbyid("test1").checked = true; } else { document.getelementbyid("test2").checked = true; } } </script> </head> <body> <input type="radio" id="test0" name="test" value="a" /> a<br /> <input type="radio" id="test1" name="test" value="b" /> b<br /> <input type="radio" id="test2" name="test" value="c" /> c<br /> <input type="button" name="click" value="choose" onclick="javascript:chooseone()" /> </body>
thanks in advance, spi
first of all, should give radio buttons same name
, otherwise act if independent buttons:
<input type="radio" name="test" id="test0" value="a" /> a<br /> <input type="radio" name="test" id="test1" value="b" /> b<br /> <input type="radio" name="test" id="test2" value="c" /> c<br />
i'm guessing source of problem. further, once this, need set 1 radio button's checked
true
, automatically remove selection other buttons.
Comments
Post a Comment