jquery implementation pull-down linkage form

Source: Internet
Author: User

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; Charset=utf-8 "/>
<title> drop-down frame form linkage </title>
<script type= "Text/javascript" src= "Jquery-1.8.3.js" ></script>
<script type= "Text/javascript" >
$ (function () {
function Objinit (obj) {
return $ (obj). html ("<option> please select </option>");
};
var arrdata={
Manufacturer 1:{Brand 1_1: "Model 1_1_1, Model 1_1_2",
Brand 1_2: "Model 1_2_1, Model 1_2_2",},
Manufacturer 2:{Brand 2_1: "Model 2_1_1, Model 2_1_2",
Brand 2_2: "Model 2_2_1, Model 2_2_2",},
Manufacturer 3:{Brand 3_1: "Model 3_1_1, Model 3_1_2",
Brand 3_2: "Model 3_2_1, Model 3_2_2",},
};
$.each (Arrdata,function (PF) {
$ ("#selF"). Append ("<option>" +pf+ "</option>");
});
$ ("#selF"). Change (function () {
Objinit ("#selT");
Objinit ("#selC");
$.each (Arrdata,function (pf,ps) {
if ($ ("#selF option:selected"). Text () = = PF) {
$.each (PS, function (pt,pc) {
$ ("#selT"). Append ("<option>" +pt+ "</option>");
});
$ ("#selT"). Change (function () {
Objinit ("#selC");
$.each (Ps,function (pt,pc) {
if ($ ("#selT option:selected"). Text () ==pt) {
$.each (Pc.split (","), function () {
$ ("#selC"). Append ("<option>" +this+ "</option>");
});
}
})
});
}
});
});

$ ("#button1"). Click (function () {
var strvalue= "Your choice of vendor:";
strvalue+=$ ("#selF option:selected"). Text ();
strvalue+= "&nbsp; Your choice of brand:";
strvalue+=$ ("#selT option:selected"). Text ();
strvalue+= "&nbsp; the model you selected:";
strvalue+=$ ("#selC option:selected"). Text ();
$ ("#divTip"). Show (). HTML (strvalue);

});

});
</script>

<body>
<div class= "Clsinit" >
Manufacturer: <select id= "Self" ><option> please select </option></select>
Brand: <select id= "SelT" ><option> Please select </option></select>
Model: <select id= "SELC" ><option> Please select </option></select>
<input id= "button1" type= "button" value= "Query" class= "BTN"/>
</div>
<div class= "Clsinit" id= "Divtip" style= "Display:none;" ></div>
</body>

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.