Javascript to get text box, drop-down box, simple example of Single-sheet value _ javascript tips-JS tutorial

Source: Internet
Author: User
This article mainly introduces a simple example of JS text box, drop-down box, and single-region value. If you need it, you can refer to it for help. 1. Text Box

1.1

Use var t = document. getElementById ("test"). value to assign the value to variable t,

1.2 of course, you can also assign the known variable value to the text box, for example:

Var m = "5 ";
Document. getElementById ("test"). value = m;

2. drop-down list box

2.1
112233

Use var s = document. getElementById ("sel"). value to getThe value selected in the box. The value = "2" option is selected by default, so the value assigned to the variable s is "2" instead of "22 ",If you wantFor example, "3" corresponds to "text value" ("33") assigned to the test text box, you can use the following method,

The Code is as follows:


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.