It's too troublesome to get the value of a Drop-down box in JavaScript (dropdown box linkage)

Source: Internet
Author: User
Javascript| pull down in JS to get the value of the Drop-down box is really a lot of trouble, compared to the ASP. NET, it's a lot of trouble.


< HTML >
< head >
< title >List</title >
< meta http-equiv= "Content-type" content= "text/html; charset=gb2312 ">
< script language= "JavaScript" >
<!--
var Onecount;
onecount=0;

subcat = new Array ();
Subcat[0] = new Array ("Xuhui District", "01", "001");
SUBCAT[1] = new Array ("Jiading", "01", "002");
SUBCAT[2] = new Array ("Huangpu", "01", "003");
SUBCAT[3] = new Array ("Nanchang", "02", "004");
SUBCAT[4] = new Array ("Jiujiang", "02", "005");
SUBCAT[5] = new Array ("Shangrao", "02", "006");

onecount=6;

function Changelocation (LocationID)
{
document.myform.smalllocation.length = 0;

var Locationid=locationid;
var i;
Document.myform.smalllocation.options[0] = new Option (' = = = = = = ALL Regions = = = = '];
For (I=0;i < onecount; i++)
{
if (subcat[i][1] = = LocationID)
{
Document.myform.smalllocation.options[document.myform.smalllocation.length]
= new Option (subcat[i][0], subcat[i][2]);
}
}

}

-->
</script >
< BODY >
< form name= "MyForm" method= "POST" >
< select Name= "Biglocation"
>
< option value= "selected" > Shanghai </option >
< option value= "a" > Jiangxi </option >
</select >
< select Name= "Smalllocation" >
< option selected Value= "" >== All areas ==</option >
</select >
</form >
< script language= "JavaScript" >
<!--
Changelocation (Document.myform.biglocation.options[document.myform.biglocation.selectedindex].value);
-->
</script >
</body >

Related Article

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.