当前位置: 动力学知识库 > 问答 > 编程问答 >

Is square brackets use with checkbox input elements PHP-only?

问题描述:

Given a construct like this:

<input type="checkbox" value="red" name="color[]" />

<input type="checkbox" value="green" name="color[]" />

<input type="checkbox" value="blue" name="color[]" />

if POST'ed to a PHP page the $_POST super-global will add the values of the checked checkboxes to an array color.

Is this a PHP-only convention or do other web-aware languages follow it also? If the latter, what other languages/libraries follow this convention?

网友答案:

I've seen it in ASP.NET MVC but it usually needs an index added, eg name="color[0]", name="color[1]", etc

Example here - Wits End with IDictionary<T,T> and ModelBinders, ASP.NET MVC 2.0

分享给朋友:
您可能感兴趣的文章:
随机阅读: