JSP Select Tag (includes hidden Select) __js

Source: Internet
Author: User

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>&nbsp;&nbsp;&nbsp;&nbsp; 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>&nbsp;&nbsp;&nbsp;&nbsp; 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

Related Article

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.