Reputation: 348
while($row = mysql_fetch_array($result)){
echo '<tr>';
echo ' <td><input name="types[]" type="checkbox" value="' . $row['type'] . '" /></td>';
echo ' <td>' . $row['type'] . '</td>';
echo ' <td><input size="3" type="text" name="quantities[]" id="TBox-' . $TBCounter . '" /></td>';
echo '</tr>';
}
it's hard to find on the internet for this solution. how do i store selected checkboxes value into types[] and quantities[]?
i would like to do a POST in php
Upvotes: 1
Views: 3844
Reputation: 23240
When you click submit button of this form, all checked values will be sended by method that you declared:
something like <form name="name" method="Post" action="file.php"> ... </form>
.
Then inside file.php
you can get types as array: $_POST['types']
. This array will contain checked values
Upvotes: 0
Reputation: 83358
how do I retrieve the types[] and quantities[]
So you want to know how to determine which of the types[]
checkbox values are checked, and store those values in an array?
You'd retrieve all the checkboxes by name, then loop through while checking the checked
property
var selected = [];
var allCbs = document.getElementsByName("types[]");
for(var i = 0, max = allCbs.length; i < max; i++)
if (allCbs[i].checked === true)
selected.push(allCbs[i].value);
Upvotes: 1