views:

83

answers:

2

i want to know the exact difference between form id and form name used in html.

+1  A: 

Do you mean on the form's elements: e.g. 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: (e.g. Yellow)

?color=y
scunliffe