Jump to content

[SOLVED] checkbox in array


EagerWolf

Recommended Posts

Hi ... I've got a problem with checkbox group...

 

<label>
<input type='checkbox' name='tv1' value='1' id='tv1'/>DVD
</label>

<label>
<input type='checkbox' name='tv1' value='2' id='tv1'/>VHS
</label>

<label>

<input type='checkbox' name='tv1' value='3' checked='checked' id='tv1'/>SAT TV
</label>

 

The problem is if more values are being checked only last is strored (value 3) .... I read about storing values into array but I am not familiar with this ... Can anyone explain how is this done ..

 

Thanks!

BR

Link to comment
https://forums.phpfreaks.com/topic/54731-solved-checkbox-in-array/
Share on other sites

Like you say, you need too put the values into an array before sending them otherwise it wont work,

 

The following edit will do just that,

<label>
<input type='checkbox' name='tv1[]' value='1' id='tv1'/>DVD
</label>

<label>
<input type='checkbox' name='tv1[]' value='2' id='tv1'/>VHS
</label>

<label>

<input type='checkbox' name='tv1[]' value='3' checked='checked' id='tv1'/>SAT TV
</label>

 

As you should be able too see the only thing needed to be done was too add brackets too the name (tv1[])

 

hope it helps

 

Stuie

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.