?? stat.jsp
字號:
<%@ page language="java" pageEncoding="GBK"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<html>
<head>
<title>統計收費</title>
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/Css/LightBlue_Css.css"/>
<script>
function toDate(){
with(document.all){
vYear=parseInt(year.options[year.selectedIndex].text)
vMonth=parseInt(month.options[month.selectedIndex].text)
day.length=0;
/*根據年和月的值生成一個日期對象調用getDate()函數得到天數*/
for(i=0;i<(new Date(vYear,vMonth,0)).getDate();i++){
day.options[day.length++].value=day.length;/*設置每一個天數的值和文本*/
day.options[day.length-1].text=day.length;
}
}
toDay();/*調用toDay()函數對年齡的有效性進行驗證*/
}
/*下面這個toDay()函數就是驗證年齡的有效性的*/
function toDay(){
if(document.form1.yearName.value=="1900"){
/*如果年份是1900,就清空,這是可選的,因為上面的年齡設的是從1970開始的,
但是加上這一步,可以讓大家學習下面這個清空年齡框的值*/
document.all("studentAge").value="";
}
else{
/*如果年份不是1900,就先得到當前計算機日期中的年份,然后減去用戶輸入的年份,
如果小于就說明年齡是無效的,否則就是有效的,并用這個年齡值作為學生的年齡。*/
vDay=parseInt(document.all.day.options[document.all.day.selectedIndex].value)
nD=new Date().getYear();/*得到當前計算機的年份*/
with(document.all){
vYear=parseInt(year.options[year.selectedIndex].text) /*得到用戶輸入的年份*/
ss = nD-vYear;/*兩者相減*/
if(ss <= 0)/*如果小于0,就說明年齡無效*/
{
///document.all("studentAge").value="無效年齡";
}
else
{
///document.all("studentAge").value=ss;
}
}
}
}
window.onload=toDate;
</script>
<script>
function toDate1()
{
with(document.all)
{
vYear=parseInt(year1.options[year1.selectedIndex].text)
vMonth=parseInt(month1.options[month1.selectedIndex].text)
day1.length=0;
/*根據年和月的值生成一個日期對象調用getDate()函數得到天數*/
for(i=0;i<(new Date(vYear,vMonth,0)).getDate();i++){
day1.options[day1.length++].value=day1.length;/*設置每一個天數的值和文本*/
day1.options[day1.length-1].text=day1.length;
}
}
toDay1();/*調用toDay()函數對年齡的有效性進行驗證*/
}
/*下面這個toDay()函數就是驗證年齡的有效性的*/
function toDay1(){
if(document.form1.yearName1.value=="1900"){
/*如果年份是1900,就清空,這是可選的,因為上面的年齡設的是從1970開始的,
但是加上這一步,可以讓大家學習下面這個清空年齡框的值*/
document.all("studentAge").value="";
}
else{
/*如果年份不是1900,就先得到當前計算機日期中的年份,然后減去用戶輸入的年份,
如果小于就說明年齡是無效的,否則就是有效的,并用這個年齡值作為學生的年齡。*/
vDay=parseInt(document.all.day1.options[document.all.day1.selectedIndex].value)
nD=new Date().getYear();/*得到當前計算機的年份*/
with(document.all){
vYear=parseInt(year.options[year1.selectedIndex].text) /*得到用戶輸入的年份*/
ss = nD-vYear;/*兩者相減*/
if(ss <= 0)/*如果小于0,就說明年齡無效*/
{
///document.all("studentAge").value="無效年齡";
}
else{
///document.all("studentAge").value=ss;
}
}
}
}
window.onload=toDate1;
</script>
</head>
<body>
<form action="<%=request.getContextPath()%>/StatServlet" name="form1" method=post>
<table class="simple textCss">
<tr>
<th align="right" width="30%"> 起始日期:</th>
<td>
<select id=year name="yearName" onchange=toDate()>
<script>
for(i=1990;i<=2010;i++)document.write("<option>"+i+"</option>")
</script>
</select>年
<select id=month name="monthName" onchange=toDate()>
<script>
for(i=1;i<=12;i++)document.write("<option>"+i+"</option>")
</script>
</select>月
<select id=day name="dayName" onchange=toDay()>
<option value="1" selected>1</option>
</select>日
</td>
</tr>
<tr>
<th align="right" width="30%"> 截止日期:</th>
<td>
<select id=year1 name="yearName1" onchange=toDate1()>
<script>
for(i=1990;i<=2010;i++)
document.write("<option>"+i+"</option>")
</script>
</select>年
<select id=month1 name="monthName1" onchange=toDate1()>
<script>
for(i=1;i<=12;i++)
document.write("<option>"+i+"</option>")
</script>
</select>月
<select id=day1 name="dayName1" onchange=toDay1()>
</select>日
</td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="統計" class="buttonClass">
<input type="button" value="退出" class="buttonClass" onclick="window.location.href='${pageContext.request.contextPath}/receiptLiuHaiQingServlet?operation=0'">
</td>
</tr>
</table>
</form>
</body>
</html>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -