What is the purpose of the `name` attribute in a checkbox input element?

Viewed 40706

I went through many online documents for the checkbox input in XHTML. Can anyone clear my doubt? What does this name field actually stand for?

Milk: <input type="checkbox" name="checkbox" value="Milk">
Chocolate: <input type="checkbox" name="checkbox" value="chocolate">
Cold Drink: <input type="checkbox" name="checkbox" value="Cold Drink">

I thought it was an identifier for that particular checkbox, which can later be used in other file by just referring their name, but given that all the checkbox had same name, why even specify it? A little confused of this.

4 Answers

The name attribute is used to identify a checkbox. Which you could parse into a object like so {checkboxName1: 'checkboxValue2', checkboxName2: 'checkboxValue2'}

Related