表单提交发送其他元素属性


Form Submission send other element attributes?

在表单提交时,除了值之外,还会提交其他内容吗?我可以提交值和数据组属性吗?

 <input type="text" id="theInput" data-group="5" value="the value" />

我只是在谈论一个PHP表单提交

只有值被提交,但您可以为数据组值添加隐藏元素。还要注意,您应该使用name属性来标识参数密钥:

<input type="text" id="theInput" name="theInput" data-group="5" value="the value" />
<input type="hidden" name="theInputGroup" value="5" />

这将返回到服务器,请求参数为:

  • theInputthe value
  • theInputGroup5

旁注:如果你通过ajax提交表单,你可以直接将组添加到参数列表中,而不是添加隐藏的输入