Reply to PHP array from HTML form checkbox or select

Your name:

Reply:


Posted by RC on 05/25/05 15:25

Order for PHP get the array from a
HTML form checkbox or select tag.
The HTML name MUST with [].
For example:

<form methos=POST action="myfile.php">
<select name="pets[]" multiple>
<option value="cat">Cat
<option value="dog">Dog
....
</select>

Or
<input type="checkbox" name="fruits[]" value="apple">
<input type="checkbox" name="fuits[]" value="orange">

</form>

But the problem is name="XXX[]" is not standard HTML, right?
Especial when my HTML file has JavaScript, JavaScript
treats the name of select or checkbox tag as an array,
so it doesn't recognized name with []. In JavaScript treats

form.pets[0].value = "cat"
Can't treats
form.pets[][0].value = "cat"

But in PHP

$pets = $_POST['pets'];
$fruits = $_POST['fruits'];

How can I solve this problem a HTML form has JavaScript and
process with PHP?

Thank Q very much in advance!

[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

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