Difference between form id and form name used in html

我想知道html中使用的表单id和表单名称之间的确切区别。


Do you mean on the form's elements: eg button/input/select & textarea elements?

If so, the name attribute is what is sent when the form is submitted. The id attribute uniquely identifies any element on the page.

The best example I can think of is radio buttons.

Each radio button belongs to a set, and the set has a name. However you may want to link to a particular button by id.

<input type="radio" name="color" id="c1" value="r"/><label for="c1">Red</label>
<input type="radio" name="color" id="c2" value="y"/><label for="c2">Yellow</label>
<input type="radio" name="color" id="c3" value="b"/><label for="c3">Blue</label>

When the form is submitted, only the selected option is sent: (eg Yellow)

?color=y

Yes...

You can have a form for email... and have many of them (from a while loop)... They are all email forms (the same) but uniquely identified by id=each user displayed on the page.

<form name="email" id="<?php echo $id; ?>" method=...
链接地址: http://www.djcxy.com/p/88048.html

上一篇: 表单的多个实例

下一篇: HTML中使用表单ID和表单名称之间的区别