solarisuser Posted April 20, 2007 Share Posted April 20, 2007 <script type="text/javascript"> function ShowValues() { checkboxes = new Array() for (i = 0; i < 4; i++) { if (document.getElementById("Box" + i).checked == true) { message = document.getElementById("Box" + i).value checkboxes = message } } document.write(checkboxes[0]) } </script> <b>Checkboxes:</b><br/> <input type="checkbox" id="Box0" name="CheckGroup" value="Item 1"/>This is Item 1<br/> <input type="checkbox" id="Box1" name="CheckGroup" value="Item 2"/>This is Item 2<br/> <input type="checkbox" id="Box2" name="CheckGroup"/>This is Item 3<br/> <br/> <input type="button" value="Show Values" onclick="ShowValues()"/> Quote Link to comment Share on other sites More sharing options...
fenway Posted April 20, 2007 Share Posted April 20, 2007 Well, first, you don't need ids for this, you already have them all as part of the the same named group from the elements array. Second, you're overwriting the message all the time. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.