jsp中插入時間控制元件
阿新 • • 發佈:2019-01-23
因工作需要,要實現資料庫篩選功能,對於時間的篩選通過控制元件進行載入,具體方法如下:
1.下載My97DatePicker專案包
2.將該專案包解壓後加載到WebRoot的Js資料夾下,載入方法:Js->Import->File System,找到你解壓檔案的位置,載入即可。
3.在<head></head>標頭檔案中用js方式匯入WdatePicker.js
<span style="font-size:14px;"><script language="javascript" type="text/javascript" src="Js/WdatePicker.js"></script></span>
注意src檔案的路徑。
4.在<body></body>檔案中新增內容:
<span style="font-size:14px;"> <input class="Wdate" type="text" onClick="WdatePicker()">--<input class="Wdate" type="text" onClick="WdatePicker()"></span>
儲存,執行即可。
具體例項:
<span style="font-size:14px;"><%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% 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 'test.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" type="text/javascript" src="js/WdatePicker.js"></script> </head> <body> <input class="Wdate" type="text" onClick="WdatePicker()">--<input class="Wdate" type="text" onClick="WdatePicker()"> </body> </html></span>
執行結果