Home > database >  A drop-down box with multiple text box linkage (using the struts 2 JSP/jquery)
A drop-down box with multiple text box linkage (using the struts 2 JSP/jquery)

Time:10-12

How can I get real pull box with multiple text box linkage now? The data obtained from the database

CodePudding user response:

<% @ page contentType="text/HTML. Charset=utf-8 "pageEncoding=" utf-8 "% & gt;


<meta HTTP - equiv="content-type" content="text/HTML. Charset=utf-8 "/& gt;

<script type="text/javascript">

Var henan=[{value: the text: "zhengzhou", "zhengzhou"}, {value: the text: "luoyang", "luoyang"}, {value: the text: "kaifeng", "kaifeng"}, {value: the text: "xinyang", "xinyang"});
Var liaoning=[{value: the text: "shenyang", "shenyang"}, {value: the text: "dalian", "dalian"}, {value: the text: "jinzhou", "jinzhou"}, {the text: "dandong," value: "dandong"});
Var hebei=[{value: the text: "shijiazhuang", "shijiazhuang"}, {the text: "chengde," value: "chengde"}, {value: the text: "tangshan", "tangshan"}, {the text: "qinhuangdao," value: "qinhuangdao}");
Var shandong=[{value: the text: "jinan", "jinan"}, {value: the text: "Qingdao", "Qingdao"}, {value: the text: "weifang", "weifang"}, {value: the text: "yantai", "yantai"});
Var shannxi=[{value: the text: "xian", "xi 'an"}, {the text: "tongchuan," value: "tongchuan"}, {the text: "baoji," value: "baoji"}, {value: the text: "hanzhong city", "hanzhong"},
{value: the text: "yan", "yanan"}, {the text: "xianyang," value: "xianyang"}, {value: the text: "practical", "shangluo"}, {value: the text: "XingPing", "xingping"};
The function getCitys (val) {
If (val=="henan") return henan;
If (val=="hebei") return hebei;
If (val=="liaoning") return liaoning;
If (val=="shandong") return shandong;
If (val=="shannxi") return shannxi.
}

The function initCity (tag) {
//the tag represents prov drop-down list
Var ops=tag. The options;
Var independence idx=tag. SelectedIndex;
Var prov=ops [independence idx] value;//the selected provinces a
Var citys=getCitys (prov);
//iterate through group add content data to the city a drop-down list
Var citySelect=document. GetElementById (" city ");

For (var I=0; i
Var option=new option (citys [I] text, citys [I] value);

CitySelect. Options [I]=option;
}
}
</script>

<body>



 
[code=HTML] [/code]

CodePudding user response:

this is the cascading drop-down list,,,,

CodePudding user response:

The drop-down list to add onchange event, ajax requests background, return data using jquery to plug in

CodePudding user response:

reference nayi_224 reply: 3/f
drop-down list to add onchange event, ajax requests background, return data using jquery to plug

Ajax haven't learned, as a basic strtus2 values on the page, the background how value

CodePudding user response:

Ajax is best for you this scenario, the code is simple, the self-study,

Can also be used as a whole to submit refresh, or other local refresh method, but too much trouble, also error-prone,

If the data quantity is little, you can under the drop down box corresponding data initialization time on page, reoccupy js operation,

CodePudding user response:

reference 5 floor nayi_224 reply:
ajax is best for you this kind of scenario, the code is simple, the self-study,

Can also be used as a whole to submit refresh, or other local refresh method, but too much trouble, also error-prone,

If the data quantity is little, you can under the drop down box corresponding data initialization time on page, then use js operation,

Good MAO xie bosses
  • Related