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()"/> Link to comment https://forums.phpfreaks.com/topic/47825-checkbox-id-value/ 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. Link to comment https://forums.phpfreaks.com/topic/47825-checkbox-id-value/#findComment-233914 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.