Put square brackets after the name of your checkboxes.....

<input type=checkbox name=list[] value="1">Home<br>
<input type=checkbox name=list[] value="2">Office<br>
etc....

Then you will be able to access all the boxes checked on your post page in an array....

$_POST['list']

shaun wrote:
Hi,

I'm not sure if this is a PHP or a JavaScript question but I have found the
following code to enable me to select all of the checkboxes on my form.

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var checkflag = "false";
function check(field) {
if (checkflag == "false") {
  for (i = 0; i < field.length; i++) {
  field[i].checked = true;}
  checkflag = "true";
  return "Uncheck all"; }
else {
  for (i = 0; i < field.length; i++) {
  field[i].checked = false; }
  checkflag = "false";
  return "Check all"; }
}
//  End -->
</script>

<form name=mon_formulaire action="" method=post>
<table>
<b>Where do you connect to the Internet from?</b><br>
<input type=checkbox name=list value="1">Home<br>
<input type=checkbox name=list value="2">Office<br>
<input type=checkbox name=list value="3">Friends' home<br>
<input type=checkbox name=list value="4">Post office<br>
<input type=checkbox name=list value="5">Internet Café<br>
<br>
<input type=button value="Check all"
onClick="this.value=check(this.form.list)">
</form>

The problem is that in the example all of the boxes are called list and i
need to name each checkbox on my form with a different user_id so that i can
collect the data sent from the form, is there a way around this?

Thanks in advance for any advice offered.






-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to