HTML表单 - 是否需要名称和ID? [英] HTML Forms - Are name and id required?
问题描述
为什么我需要< input>
表单元素的名称和 id 属性?
哪些用于POST数据发送,哪些可以排除?
如果您打算处理该字段,则服务器端使用 name
,这是必需的。 id
只有在标签
元素被屏幕阅读器点击并访问时才能触发/调用窗体控件(
< form method = POST action =form-processor.php>
< input name = first_name value = john>
< / form>
结果
$ _ POST = array('first_name'=>'john');
如果方法是 GET
,它会被追加到查询字符串:
对于带有隐藏输入的查询字符串追加很流行: Why do I need the name and id attributes for Which is used for POST data sending and which can I exclude? results in If the method is it's popular for query string appending with hidden inputs: 这篇关于HTML表单 - 是否需要名称和ID?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! http://site-name.com/form-handler.php?first_name=john $ c $
< / p> input type =hiddenname =qvalue =1>
<input>
form elements?name
is used by the server-side, this is necessary if you plan to process the field. id
is only so label
elements, when clicked and accessed by screen-readers, can trigger/invoke the form controls ( inputs, selects ).<form method=POST action="form-processor.php">
<input name=first_name value=john>
</form>
$_POST = array( 'first_name' => 'john' );
GET
, it's appended to the query string:http://site-name.com/form-handler.php?first_name=john
<input type="hidden" name="q" value="1">