About the value of the SELECT tag

Source: Internet
Author: User
We know that only the values of input, textarea, and select three types of tags in web development will be submitted to the server. For example, the input tag has attributes such as title, type, disabled, but these properties are for display purposes and cannot be modified by the user.

For input, the textarea tag is very obvious in its value, input is written dead when defined, and the value of the TEXTAREA tag is well defined (the user writes its value). However, the value of the SELECT tag has some differences when it is used: You can set the Value property in <option>, and then commit the set value directly to the server.

<select name= "area" >
<option value= "BJ" > Beijing </option>
<option value= "sh" > Shanghai </ option>
<option value= "JZ" > Jiaozuo </option>
</select>

At the time of submission, if "Beijing" is selected, the "AREA=BJ" is submitted to the server. In the <option> default Value property, the selected text is submitted when the data is submitted.

1 <select name= "area" >
2 <option > Beijing </option>
3 <option > Shanghai </option>
4 < Option > Jiaozuo </option>
5 </select>

At the time of submission, if "Beijing" is selected, it is "area= Beijing" submitted to the server.

A further bold speculation follows this: the so-called Select tag is actually a text element that can be selected (restricted selection), which is equivalent to filling the text with this option when an option is selected. So the submitted data is naturally the "value" that is filled in the "text".

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.