Example of onchange event usage of select in jsp
Updated: October 20, 2015 12:29:27 Author: hacker0825
This article mainly introduces the onchange event usage of select in jsp. It analyzes the relevant techniques of JSP database query, traversal and JavaScript response mouse event processing in a more detailed manner. Friends who need it can refer to it
This article describes the usage of onchange event in jsp. Share it for your reference, as follows:
<script language = "JavaScript"> var onecount; onecount=0; subcat = new Array(); <% int count = 0; rs1 = ("select hydm,zhydm,zhymc from zhy ");//Read data while(()) { String selhydm=("hydm").trim(); String zhydm=("zhydm").trim(); String zhymc=("zhymc").trim(); %> subcat[<%=count%>] = new Array("<%=zhydm%>","<%=selhydm%>","<%=zhymc%>");//Produce an array <% count = count + 1; } if(rs1!=null) (); %> onecount=<%=count%>; function changelocation(id) { document. = 0; var hydm=id; var i; document.[0] = new Option('Choose a sub-industry category',''); for (i=0;i < onecount; i++) { if (subcat[i][1] == hydm) { document.[document.] = new Option(subcat[i][2], subcat[i][0]); } } } </script> <table width="500" border="0" cellspacing="0" cellpadding="0" align="center"> <tr> <td width="180" height="20" align="right">Select industry classification:</td> <td width="320"> <select name="selhy" onChange="changelocation(document.[document.].value)" size="1" > <option value="2">请Select industry classification</option> <% rs = ("select * from hy"); while(()) { String hydm=("hydm").trim(); String hymc=("hymc").trim(); %> <option value="<%=hydm%>"><%=hymc%></option> <% } if(rs!=null) (); %> </select> </td> </tr> <tr> <td height="20" align="right">Select sub-industry classification:</td> <td> <select name="selzhy" > <option value="" selected>请Select sub-industry classification</option> </select> </td> </tr> </table> <form name=form1> <select name=province onchange="cityName()"> <option value="">Please select the provincial name</option> </select> <select name=city> <option value="">Please select the city name</option> </select> </form> <script language=javascript> var city1 = ["Hangzhou", "Ningbo", "Wenzhou", "Shaoxing", "Jinhua", "Huzhou"]; var city2 = ["Nanjing", "Suzhou", "Wuxi", "Changzhou", "Zhenjiang", "Xuzhou"]; var city3 = ["Hefei", "Xi County", "Huangshan", "Qimen", "Xuening"]; var city4 = ["Nanchang", "Jiujiang", "Ganzhou", "Shangrao", "Xinyu", "Jingdezhen"]; var provinceName = ["Zhejiang", "Jiangsu", "Anhui", "Jiangxi"]; function province() { var e = document.; for (var i=0; i<; i++) (new Option(provinceName[i], provinceName[i])); } function cityName(n) { var e = document.; for (var i=; i>0; i--) (i); if (n == 0) return; var a = eval("city"+ n); //Get the array name of the city for (var i=0; i<; i++) (new Option(a[i], a[i])); } function () { province(); //At the initial content to the drop-down menu for the name of the province } </script>
I hope this article will be helpful to everyone's JSP programming.
Related Articles
Use JS to display countdown digital clock effect
This article mainly introduces the web countdown digital clock effect implemented by JS. It is a very practical JavaScript countdown special effect, which has certain reference value. Friends who need it can refer to it.2016-10-10Detailed explanation and principle analysis of Session in JSP
This article mainly introduces the detailed introduction of Session in JSP. I hope this article can help you and let you understand and master the usage of Session. Friends who need it can refer to it2017-10-10JSP page value transmission garbled filtering method
This article mainly introduces the garbled filtering method of JSP page value transmission, and analyzes the garbled filtering code and configuration method of JSP page value transmission in a complete example. Friends who need it can refer to it2016-04-04Read client information using JSP
Read client information using JSP...2006-10-10Four methods of passing parameters in jsp
This article mainly introduces four methods of passing parameters in JSP, which are of good reference value. Let's take a look with the editor below2017-03-03Declaration and use of variables and methods in jsp
This article mainly introduces the declaration and use of variables and methods in jsp. It analyzes the declaration of variables in jsp, the definition and use of methods in jsp in the form of examples. Friends who need it can refer to it2015-12-12Detailed explanation of the solution to the problem of Chinese garbled in JSP
This article mainly introduces a detailed explanation of the solution to the problem of garbled Chinese in JSP. The example code is introduced in this article in detail, which has certain reference learning value for everyone's study or work. Friends who need it, please learn with the editor below.2020-08-08jsp source code example 3 (get various parameters of jsp)
jsp source code example 3 (get various parameters of jsp)...2006-10-10Why learn Hibernate?
Why learn Hibernate? ...2006-10-10Introduction to json implementation jsp paging example (with renderings)
JSON is both simple and easy to understand and transmits quickly. It can also integrate well with JavaScript; without adding jars, it can complete the jsp paging problem well. Next, let me introduce how to implement it.2013-04-04