Reply to Re: How to give a value to non selected checkbox

Your name:

Reply:


Posted by Ken Robinson on 04/25/06 20:20

M wrote:
> Hello,
>
> I would like to get a value for a non selected checkbox in a form.
>
> Imagine my form contains :
>
> <input type='checkbox' name='t[0]' value='1'>
> <input type='checkbox' name='t[1]' value='1'>
>
> When I analyse $t, if first checkbox is not selected and second is, I have :
> $t[0] has no value. $t[1] equals 1
> and count($t) equals 1
>
> I would like to find a way to get :
> $t[0] equals 0. $t[1] equals 1
> and count($t) equals 2

You can "pre-initialize the values by using a hidden field. That way if
the checkbox isn't checked, the value from the hidden field will get
passed back. If it is checked, you get the checked value:

<input type="hidden" name="t[0]" value="0">
<input type="hidden" name="t[1]" value="0">
<input type='checkbox' name='t[0]' value='1'>
<input type='checkbox' name='t[1]' value='1'>

Ken

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация