Find and set the current select option in HTML

Source: Internet
Author: User
1 < Html >
2 < Head >
3 < Meta HTTP-equiv = "Content-Type" Content = "Text/html; charset = gb2312" >
4 < Title > Untitled document </ Title >
5 < Script Language = Javascript >
6 Function Btntest_onclick ()
7 {
8 VaR Testoptions = Test. options;
9 VaR I = 0 ;
10 For (I = 0 ; I < Testoptions. length; I ++ )
11 {
12 If ( 2 = Test. Options [I]. value)
13 {
14Test. selectedindex=I
15}
16 }
17 }
18 </ Script >
19 </ Head >
20 < Body >
21 < Select Name = Test Size = 1 >
22 < Option Value = "1" > A </ Option >
23 < Option Value = "2" > B </ Option >
24 </ Select >
25 < Input Type = Button Name = Btntest Onclick = "Btntest_onclick ()" Value = "Test" >
26 </ Body >
27 </ Html >

This is also a friend's question (as long as someone asks, maybe someone else will ask, and it will be OK to send a link later)

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.