rondog Posted July 11, 2008 Share Posted July 11, 2008 Ok I am trying to accomplish two things and I cant seem to get both of them to work together. I have a series of check boxes..When I submit, I need to put all the ones that are checked into an array..thats fine if I name each checkbox 'list[]'. They echo out perfectly. The problem is now my select all and deselect all dont work. I get a syntax error because they are named 'list[]' and not 'list' Any idea on how to do both?? my php to get each value of the selected check boxes: <?php if(isset($_POST['review'])) { $list = $_POST['list']; while(list($key,$val) = @each($list)) { echo "$val, "; } } ?> my javascript to select all/deselect all: function checkAll(field) { for (i = 0; i <field.length; i++) { field[i].checked = true; } } function uncheckAll(field) { for (i = 0; i <field.length; i++) { field[i].checked = false; } } Quote Link to comment Share on other sites More sharing options...
xtopolis Posted July 12, 2008 Share Posted July 12, 2008 Give them a name and id? name="list[]" for PHP, and id="list" for javascript? I'm 99% sure you can make your funcs get elements by id or something similar. edit: or possibly what you already have would work if you use the id like I mentioned above Quote Link to comment Share on other sites More sharing options...
rondog Posted July 12, 2008 Author Share Posted July 12, 2008 Hey cool man that worked...I should of known that! 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.