Click to See Complete Forum and Search --> : Input tag name issues


bp_travis
07-31-2007, 12:43 PM
I have a pretty complex situation here. I have a form that has 100+ checkboxes that are all name differently. The value of the checkbox has to be a number because of a javascript script that adds up their checked values. I want a way to insert into the database the name of the field and not the actual value. Is there a way to get PHP to get the <input tag> names and spit them out to you? Also, how to do you loop through values submitted in a form? Thanks

NogDog
07-31-2007, 05:21 PM
<input type="checkbox" name="check[name1]" value="1">1
<input type="checkbox" name="check[name2]" value="2">2
<input type="checkbox" name="check[name3]" value="3">3


if(count($_POST['check'])) // at least one was checked
{
foreach($_POST['check'] as $name => $value)
{
// do whatever you want with $name and $value
}
}