Description
The select tag is mainly two points, one is the related JS function, and one is the option tag.
This column also contains a hidden select, which is invoked in the JS function. This takes into account the speed and sequence of loading to avoid the problem of using Java code directly in the JS function.
/*jsp Content * *
<div style= "width:40%; float:left;"
/<%=cssdir%>/img/san_funarea_ Search.png "width=" height= "align=" absmiddle/> Please select the query type
<select name= "field" class= " Select "Onchange=" Shownext () "
<option value=" Carno "<%if (field.equals (" Carno ")) Out.print ("selected"); %>> License plate number </OPTION>
<option value= "Carname" <%if ("Field.equals") Out.print ("selected"); %>> Vehicle name </option>
<option value= "Deptname" <%if ( Field.equals ("Deptname")) Out.print ("selected"); %>> Department </option>
</select>
</div>
<div style= "width : 60%; Float:right "id=" mydiv "></div>
Hide Select
<div>
<select id= "Dept" name= "dept" class= "select" style= "Display:none" >
<option value= "" > Please select </option>
<%
ResultSet getdeptrs = Db.executequery ("Select T.dept,t.deptname from Pub_dept_manager t where unit= '" +cua.getunitcode () + "' and Parentcode= '" +cua.getunitcode () + "'");
while (Getdeptrs.next ()) {
if (Keyvalue.equals (getdeptrs.getstring (2)))
Out.print ("<option value= '" +getdeptrs.getstring (2) + "' Selected>" +getdeptrs.getstring (2) + "</option>") ;
Else
Out.print ("<option value= '" +getdeptrs.getstring (2) + "' >" +getdeptrs.getstring (2) + "</option>");
}
Getdeptrs.close ();
%>
</select>
</div>
<script language= "JavaScript" >
Query jump
var keyvalue = "<%=keyvalue%>";
var yearvalue = "<%=yearvalue%>";
var year = "<%=year%>";
Displays the text box or Drop-down box for the input keyword, depending on the query criteria you choose
function Shownext () {
if (year = = "CurrentYear") {
The year value passed from the previous page is not empty and is a string "CurrentYear"
Yearvalue = "<%=currentYear%>";
}
var selectvalue = Document.form1.field.options[document.form1.field.selectedindex].value;
Mydiv.innerhtml= ' <table cellpadding= "0" cellspacing= "0" border=0><tr><td> "
+ ' keywords: <input size= "name=" KeyValue "type=" text "id=" keyvalue "title=" Please enter the keyword to find "value=" ' +keyvalue+ ' ">"
+ ' </td><td> year: '
+ ' <input size= "6" name= "Yearvalue" type= "text" des= "year" id= "Yearvalue" maxlength= "4" dtype=year title= "Please enter the year to find" Value= "' +yearvalue+ '" ></td> "
+ ' <td><a href= ' javascript:query (); "class= Main_fun_button" > Query </a></td></tr></ Table> ';
Role categories
if (Selectvalue = = "Deptname") {
Mydiv.innerhtml= ' <table cellpadding= "0" cellspacing= "0" border=0><tr><td> "
+ ' keywords: <select id= "KeyValue" name= "keyvalue" class= "select" > ' +document.all.dept.innerhtml
+ ' </select></td><td> year: '
+ ' <input size= ' name= "Yearvalue" type= "text" des= "year" id= "Yearvalue" maxlength= "4" dtype=year title= "Please enter the year to find" Value= "' +yearvalue+ '" ></td> "
+ ' <td><a href= ' javascript:query (); "class= Main_fun_button" > Query </a></td></tr></ Table> ';
}
Keyvalue= "";
Yearvalue = "";
if (document.form1.keyvalue!=null)
Document.form1.keyvalue.focus ();
}
</script> related JS functions