/    Sign up×
Community /Pin to ProfileBookmark

Input tag name issues

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

to post a comment
PHP

1 Comments(s)

Copy linkTweet thisAlerts:
@NogDogJul 31.2007 — [code=html]
<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
[/code]

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

Success!

Help @bp_travis spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...