Finding the values of all of the checked checkboxes in php
Hi so have form with a vote and what i want to do is what ever options they tick, when they click submit it the posts all the values of the check boxes ticked to the same page al开发者_JS百科lowed me to echo them
i have tried just doing this
if(isset($_POST['submitted'])) {
$list = $_POST['vote']; echo $list; }
but that only echos the last value selected
Thanks, Ben
ok so i have a fix by changing the name to an array but i got a problem because i used javascript functions like this
checkAll(document.form.vote)
so what do i change it to?
When you name the inputs you can give it a name like name="checkboxes[]"
and that will throw it in an array when it posts to the next page. Hope that helps!
In your form set name attribut like this:
<input type="checkbox" name="vote[]" />
Then you can:
foreach($_POST['vote'] as $vote){
echo $vote;
}
精彩评论