• 年月日下拉联动代码


    这是JS的代码:

     function getSDay(){
               var year ;
               var month ;
               var maxday=0 ;
              
               with( document.sedate.syear ){
                year = options[selectedIndex].text; 
               }
              
               with( document.sedate.smonth ){
                month = options[selectedIndex].text;
               }
              
               if( month==1 | month==3 | month==5 | month==7 | month==8 | month==10 | month==12 ){
                 maxday = 31 ;
               }else if( month==4 | month==6 | month==9 | month==11 ){
                 maxday = 30 ;
               }else if( month == 2 ){
                 if( (year%4==0 & year%100!=0) | year%400==0 ){
                   maxday = 29 ;
                 }else{
                  maxday = 28 ;
                 }
               }
              
               with( document.sedate.sday ){
                length = maxday+1;
                options[0].text="--不限";
              options[0].value="--不限";
                for( var i=1;i<maxday+1;i++ ){
                  options[i].text=i;
                  options[i].value=i;
                }
               }
             }
            
             function getEDay(){
            var year ;
            var month ;
            var maxday=0 ;
           
            with( document.sedate.eyear ){
             year = options[selectedIndex].text; 
            }
           
            with( document.sedate.emonth ){
             month = options[selectedIndex].text;
            }
           
            if( year!="--不限" ){
             if( month==1 | month==3 | month==5 | month==7 | month==8 | month==10 | month==12 ){
               maxday = 31 ;
             }else if( month==4 | month==6 | month==9 | month==11 ){
               maxday = 30 ;
             }else if( month == 2 ){
               if( (year%4==0 & year%100!=0) | year%400==0 ){
                 maxday = 29 ;
               }else{
                maxday = 28 ;
               }
             }
            }
           
            with( document.sedate.eday ){
              length = maxday+1;
              options[0].text="--不限";
              options[0].value="--不限";
                for( var i=1;i<maxday+1;i++ ){
                  options[i].text=i;
                  options[i].value=i;
                }
               }
          }
    这是JSP的代码:
    <%@ page language="java" import="java.util.*" pageEncoding="GBK"%>
    <%
    String path = request.getContextPath();
    String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
    %>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
      <head>
        <base href="<%=basePath%>">
       
        <title>My JSP 'date.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 language="javascript" src="MyJavaScript/date.js" ></script>
      </head>
       
      <body>
        <form action="" name="sedate">
     
         <table border="1"  width="1000" align="center" >
          <tr>
           <td>
            选择时间:
           </td>
           <td>
            <select  name="syear" onchange="getSDay()" >
                <option selected>--不限</option>
                <%
                 for( int i=0;i<30;i++ ){
                 %>
                <option><%=1990+i%></option>
                <% }%>
         </select>
        
           </td>
           <td></td>
           <td>
            <select name="smonth" onchange="getSDay()">
                <option selected>--不限</option>
                <%
                 for( int i=1;i<13;i++ ){
                 %>
                <option ><%=i%></option>
                <% }%>
         </select>
           </td>
           <td></td>
           <td>
            <select name="sday" >
                <option selected>--不限</option>
         </select>
           </td>
           <td></td>
           <td></td>
           <td>
            <select name="eyear"  onchange="getEDay()">
                <option selected>--不限</option>
                <%
                 for( int i=0;i<30;i++ ){
                 %>
                <option><%=1990+i%></option>
                <% }%>
         </select>
           </td>
           <td></td>
           <td>
            <select name="emonth" onchange="getEDay()">
                <option selected>--不限</option>
                <%
                 for( int i=1;i<13;i++ ){
                 %>
                <option ><%=i%></option>
                <% }%>
         </select>
           </td>
           <td></td>
           <td>
            <select name="eday">
                <option selected>--不限</option>
         </select>
           </td>
           <td></td>
          </tr>
          </table>
          </form>
           </body>
    </html>

    在WEBROOT下建个文件夹MyJavaScript,把JS放进去,然后把文件夹和JS放WEBROT下,就可以了。

  • 相关阅读:
    MVC 易忘备留
    SQL SERVER 常用易忘语句备留
    ThreadStatic特性
    jstack用法
    PV、TPS、QPS是怎么计算出来的?
    性能测试Loadrunner与Mysql
    JVM性能调优监控工具jps、jstack、jmap、jhat、jstat、hprof使用详解
    【MySQL】计算 TPS,QPS 的方式
    【转】jquery 1.3 的 live方法
    【转】HttpCompress
  • 原文地址:https://www.cnblogs.com/webqiand/p/4609732.html
Copyright © 2020-2023  润新知