unemployment Posted January 30, 2011 Share Posted January 30, 2011 This fails on me. Firebug says msg is undefined. function selectone () { var msg = document.getElementsByName('pm'); var i = 0; for(i; i < msg.elements.length; i++) { if(msg.elements[i].checked === checked) { document.getElementById('multiple_action').disabled = false; document.getElementById('drop_button').setAttribute("class", "drop_button"); } else { document.getElementById('multiple_action').disabled = true; document.getElementById('drop_button').setAttribute("class", "drop_button disabled"); } } } Link to comment https://forums.phpfreaks.com/topic/226098-select-check-box/ Share on other sites More sharing options...
brianlange Posted January 30, 2011 Share Posted January 30, 2011 Can you post html or provide a url? Link to comment https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167395 Share on other sites More sharing options...
unemployment Posted January 30, 2011 Author Share Posted January 30, 2011 Can you post html or provide a url? HTMl below <form method="get" id="pm" name="pm" onsubmit="return false;"> <table class="messages"> <tr> <td class="box_column"> <label><input type="checkbox" name="pmcheckbox" onclick="selectone();" value="pm<?php echo $message['message_id']; ?>" /></label> </td> </tr> </form> Link to comment https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167398 Share on other sites More sharing options...
sunfighter Posted January 30, 2011 Share Posted January 30, 2011 This looks like you have more than one checkbox. I think you should send the id of the ckbox to the function. And msg is empty. Would document.getElementsByTagName("INPUT"); work better for you? P.S. you don't have an id for any of the checkboxes. Link to comment https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167437 Share on other sites More sharing options...
unemployment Posted January 30, 2011 Author Share Posted January 30, 2011 This looks like you have more than one checkbox. I think you should send the id of the ckbox to the function. And msg is empty. Would document.getElementsByTagName("INPUT"); work better for you? P.S. you don't have an id for any of the checkboxes. Is this what you meant? I added an id to the checkbox of msgcheckbox. function selectone () { var msg = document.getElementsById('pm'); var i = 0; for(i; i < msg.elements.length; i++) { if(msg.elements[i].checked == true) { document.getElementById('multiple_action').disabled = false; document.getElementById('drop_button').setAttribute("class", "drop_button"); } else { document.getElementById('multiple_action').disabled = true; document.getElementById('drop_button').setAttribute("class", "drop_button disabled"); } } } Link to comment https://forums.phpfreaks.com/topic/226098-select-check-box/#findComment-1167464 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.