Forum Moderators: coopster
job1
job24
job55
job100
...
..
job495
The user is able to select the jobs by ticking them.
When the form is posted, how do I retrieve the ticked boxes? I need their names.
It was easily done in ASP, but I can't seem to find a PHP equivalent. Any help appreciated.
You need to name your input element with brackets.
<input name="jobs[]" type="checkbox" />
[php.net...]
You could try something like this, assuming that the checkboxes were the only fields in your form.
form.php
print "
<form action='submit.php' method='post'>
$job_number<input type='checkbox' name='$job_number' value='$job_number'><!--more checkboxes depending on how you want it to be printed-->
</form>
";
submit.php
print_r($_POST);
This just prints out all of the selected ones. If you want to do something with them, you could try something like this:
$len = count($_POST);
$keys = array_keys($_POST);
for($i = 0; $i < $len; $i++)
{
$key = $keys[$i];
$job = $_POST[$key];
echo $job."<br>";
}
I hope this works because i haven't tested it. Good luck
eelix
eelix