简体   繁体   中英

What is the html <select> element's name attribute's value

I know this is very basic, but for the life of me, I can't find a web page anywhere that explains what the value is of the name attribute of the HTML <select> element. Can someone please point me to a specification, or any website, for that matter, that explains what is the value of the name attribute of the <select> element? Thank you

If a <select> element is inside a <form> The name attribute value will be the name of the field submitted by the form.
This value can be read in the submitted page from the Request.
For example if you have a <select name="x"> and the selected <option> value is y, then in the submitted page it will look something like this:
Request["x"] will be equal y

It's something like:

The name attribute specifies the name for a drop-down list. The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

For example:

 <form> <select name="cars"> <option value="juice">juice</option> <option value="coca cola">coca cola</option> <option value="pepsi">pepsi</option> <option value="sprite">sprite</option> </select> <input type="submit"> </form> 

It's only a attribute for specify or reference the element.. No more, no less..

The name attribute is common for all input elements, here is the explaination from W3Schools :

The name attribute specifies the name of an element.

The name attribute is used to reference elements in a JavaScript, or to reference form data after a form is submitted.

Note: Only form elements with a name attribute will have their values passed when submitting a form.

It can take any value you want.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM