NameSilo

Passing an array of checkboxes via POST - How?

Spaceship Spaceship
Watch

user-7256

VIP Member
Impact
111
Hi,

Let's say I have an "array" of checkboxes on a form:

<input type="check" name="dn[1]">
<input type="check" name="dn[2]">
<input type="check" name="dn[3]">
<input type="check" name="dn[4]">
<input type="check" name="dn[5]">
<input type="check" name="dn[6]">

Then I submit it. How can I make variable $dn an array? Is there a better way to do this? I need to be able to find out which checkboxes are checked.

Advice appreciated,
-Matt
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
AfternicAfternic
Close . .

What I do is this:

<input type="check" name="dn[]">
<input type="check" name="dn[]">
<input type="check" name="dn[]">
<input type="check" name="dn[]">
<input type="check" name="dn[]">
<input type="check" name="dn[]">

Then (at least in PHP) - you will get an array named "$dn" with the posted values.

-Bob
 
0
•••
Really? Then will it fill in the number for the array element automatically?

EDIT: Am checking it out now...

Works! Thanks!
 
0
•••
Dynadot — .com Registration $8.99Dynadot — .com Registration $8.99

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Zero Commission
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back