<! Doctype html public "-// W3C // dtd html 4.01 Transitional // EN"> <Html> <Head> <Base href = "<% = basePath %>"> <Title> My JSP 'city. jsp 'starting page </title> <Meta http-equiv = "pragma" content = "no-cache"> <Meta http-equiv = "cache-control" content = "no-cache"> <Meta http-equiv = "expires" content = "0"> <Meta http-equiv = "keywords" content = "keyword1, keyword2, keyword3"> <Meta http-equiv = "description" content = "This is my page"> <! -- <Link rel = "stylesheet" type = "text/css" href = "styles.css"> --> <Script type = "text/javascript" src = "js/jquery-1.7.2.min.js"> </script> <Script type = "text/javascript"> $ (Document). ready (function (){ // Save $. Ajax ({url: "xml/City. xml ", Success: function (xml ){ $ (Xml). find ("province"). each (function (){ Var t = $ (this). attr ("name"); // this-> $ ("# DropProvince"). append ("<option>" + t + "</option> "); }); } }); // City $ ("# DropProvince"). change (function (){ $ ("# SCity> option"). remove (); $ ("# SArea> option"). remove (); Var pname = $ ("# DropProvince"). val (); $. Ajax ({url: "xml/City. xml ", Success: function (xml ){ /// Search for all the first-level child elements (that is, the city) under <province>) $ (Xml). find ("province [name = '" + pname + "']> city"). each (function (){ Var city = $ (this). attr ("name"); // this-> $ ("# SCity"). append ("<option>" + city + "</option> "); }); /// Search for all the first level child elements (that is, the region) under <city>) Var cname = $ ("# sCity"). val (); $ (Xml). find ("city [name = '" + cname + "']> area"). each (function (){ Var area = $ (this). attr ("name"); // this-> $ ("# SArea"). append ("<option>" + area + "</option> "); }); } }); }); // Zone $ ("# SCity"). change (function (){ $ ("# SArea> option"). remove (); Var cname = $ ("# sCity"). val (); $. Ajax ({url: "xml/City. xml ", Success: function (xml ){ /// Search for all the first level child elements (that is, the region) under <city>) $ (Xml). find ("city [name = '" + cname + "']> area"). each (function (){ Var area = $ (this). attr ("name"); // this-> $ ("# SArea"). append ("<option>" + area + "</option> "); }); } }); }); }); </Script> </Head> <Body> <Form id = "form1"> <Div> <Select id = "DropProvince" style = "width: 100px;"> <Option> select </option> </Select> <Select id = "sCity" style = "width: 100px;"> <Option> select a city </option> </Select> <Select id = "sArea" style = "width: 100px;"> <Option> select a zone </option> </Select> </Div> </Form> </Body> </Html> |