search.asp
上传用户:syzzy1975
上传日期:2022-07-17
资源大小:670k
文件大小:8k
源码类别:

Jsp/Servlet

开发平台:

Java

  1. <%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
  2. <%
  3. %><!--#include file="manage/inc/config.asp"--> 
  4. <!--#include file="inc/conn.asp"--> 
  5. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  6. <html>
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=gb2312">
  9. <title>406网络书店</title>
  10. <link href="style.css" rel="stylesheet" type="text/css">
  11. </style>
  12. <!-- European format dd-mm-yyyy -->
  13. <script language="JavaScript" src="calendar.js"></script>
  14. </head>
  15. <body>
  16. <!--#include file="head.htm"-->
  17. <table width="780" border="0" align="center" cellpadding="0" cellspacing="0">
  18.   <tr>
  19.     <td width="219" align="left" valign="top"><!--#include file="left.asp"--></td>
  20.     <td width="561" align="left" valign="top">
  21.       <br>      <script language=javascript>
  22. var whitespace = " tnr";
  23. function IsWhitespace (s)
  24. {
  25.   var i;
  26.   if (IsEmpty(s)) return true;
  27.   for (i = 0; i < s.length; i++)
  28.   {
  29.     var c = s.charAt(i);
  30.     if (whitespace.indexOf(c) == -1) return false;
  31.   }
  32.   return true;
  33. }
  34. function IsEmpty(s)
  35.   return ((s == null) || (s.length == 0))
  36. }
  37. function IsDate(fDate)
  38. {
  39.     var arrDaysInMonth=new Array(12);
  40.     arrDaysInMonth[1]=31;
  41.     arrDaysInMonth[2]=29;
  42.     arrDaysInMonth[3]=31;
  43.     arrDaysInMonth[4]=30;
  44.     arrDaysInMonth[5]=31;
  45.     arrDaysInMonth[6]=30;
  46.     arrDaysInMonth[7]=31;
  47.     arrDaysInMonth[8]=31;
  48.     arrDaysInMonth[9]=30;
  49.     arrDaysInMonth[10]=31;
  50.     arrDaysInMonth[11]=30;
  51.     arrDaysInMonth[12]=31;
  52.     
  53.     if (IsEmpty(fDate))
  54.         return true
  55.         
  56.     var NameList=fDate.split("-");
  57.     if (NameList.length!=3)
  58.         return false
  59.     
  60.     if (!(IsYear(NameList[0]) && IsMonth(NameList[1]) && IsDay(NameList[2])) )
  61.         return false
  62.     
  63.     if ( NameList[1]>arrDaysInMonth[NameList[1]] )
  64.         return false
  65.         
  66.     if ( (NameList[1]==2) && (NameList[2]>DaysInFebruary(NameList[0]) ) )
  67.         return false
  68.         
  69.     return true
  70. }
  71. function search()   
  72. {
  73.   var name          = document.forms['frmdata'].elements['name'].value;
  74.   var author        = document.forms['frmdata'].elements['author'].value;
  75.   var manufacturer  = document.forms['frmdata'].elements['manufacturer'].value;
  76.   var smallprice    = document.forms['frmdata'].elements['smallprice'].value;
  77.   var largeprice    = document.forms['frmdata'].elements['largeprice'].value;
  78.   var enabledate    = document.forms['frmdata'].elements['enabledate'].value;
  79.   var expiredate    = document.forms['frmdata'].elements['expiredate'].value;
  80.   if (!IsWhitespace(enabledate))
  81.   {
  82.     if (!IsDate(enabledate))
  83.     {
  84.       alert("出版日期 开始日期格式错误!");
  85.       return false;
  86.     }
  87.   }
  88.   if (!IsWhitespace(expiredate))
  89.   {
  90.     if (!IsDate(expiredate))
  91.     {
  92.       alert("出版日期 结束日期格式错误!");
  93.       return false;
  94.     }
  95.   }
  96.   var allNotEmpty = (!IsWhitespace(name)) ||
  97.              (!IsWhitespace(author)) ||
  98.              (!IsWhitespace(manufacturer)) ||
  99.              (!IsWhitespace(smallprice)) ||
  100.              (!IsWhitespace(largeprice))||
  101.              (!IsWhitespace(enabledate)) ||
  102.              (!IsWhitespace(expiredate));
  103.   if (!allNotEmpty)
  104.   {
  105.       alert("必需输入一个搜索条件");
  106.       return false;
  107.   }
  108.   if (!IsWhitespace(smallprice))
  109.   {
  110.     if (!IsPlusNumeric(smallprice))
  111.     {
  112.       alert("价格数据不合法");
  113.       return false;
  114.     }
  115.   }
  116.   if (!IsWhitespace(largeprice))
  117.   {
  118.     if (!IsPlusNumeric(largeprice))
  119.     {
  120.       alert("价格数据不合法");
  121.       return false;
  122.     }
  123.   }
  124.   if ((!IsWhitespace(enabledate)) && (!IsWhitespace(expiredate)))
  125.   {
  126.   if (enabledate>expiredate)
  127.   {
  128.     alert("出版日期范围错误");
  129.         return false;
  130.   }
  131.   }
  132.   if ((!IsWhitespace(smallprice)) && (!IsWhitespace(largeprice)))
  133.   {
  134.   if (parseFloat(smallprice)>parseFloat(largeprice))
  135.   {
  136.     alert("价格范围错误");
  137.         return false;
  138.   }
  139.   }
  140. }
  141.                 </script>      <br>      <table cellpadding="0" cellspacing="0" border="0">
  142.         <tr>
  143.           <td><img src="images/w.gif"></td>
  144.           <td style="color:#415373">搜索图书</td>
  145.         </tr>
  146.       </table>      <br>      <FORM name=frmdata  method=get action="rsearch.asp">
  147.         <TABLE cellSpacing=10 cellPadding=0 width="100%" border=0>
  148.          
  149.           <TBODY>
  150.             <TR>
  151.               <TD align=right width="31%" height=30>商品名称:</TD>
  152.               <TD width="69%"><INPUT name=name class="inputstyle">
  153.               </TD>
  154.             </TR>
  155.             <TR>
  156.               <TD align=right width="31%" height=30>作者名称:</TD>
  157.               <TD width="69%"><INPUT name=author class="inputstyle">
  158.               </TD>
  159.             </TR>
  160.             <TR>
  161.               <TD align=right width="31%" height=30>出版社:</TD>
  162.               <TD width="69%"><INPUT name=manufacturer class="inputstyle">
  163.               </TD>
  164.             </TR>
  165.             <TR>
  166.               <TD align=right width="31%" height=28>出版时间:</TD>
  167.               <TD vAlign=center width="69%"><INPUT name=enabledate class="inputstyle" size=12>
  168.                 <a 
  169.             href="javascript:cal1.popup();"><img height=16 alt=点击选择日期 
  170.             src="images/cal.gif" width=16 border=0></a>              &nbsp;至&nbsp;
  171.                   <INPUT name=expiredate class="inputstyle" size=12>
  172.                   <a 
  173.             href="javascript:cal2.popup();"><img height=16 alt=点击选择日期 
  174.             src="images/cal.gif" width=16 border=0></a> <script language=JavaScript>
  175.   var cal1 = new calendar1(document.forms['frmdata'].elements['enabledate']);
  176.   cal1.year_scroll = true;
  177.   cal1.time_comp = false;
  178.   var cal2 = new calendar1(document.forms['frmdata'].elements['expiredate']);
  179.   cal2.year_scroll = true;
  180.   cal2.time_comp = false;
  181.                   </script></TD>
  182.             </TR>
  183.             <TR>
  184.               <TD align=right width="31%" height=30>价格范围:</TD>
  185.               <TD width="69%">                <input name="smallprice" type="text" id="smallprice"  size="5" >
  186.             至
  187.               
  188.               <input name="largeprice" type="text" id="largeprice" 
  189.  size="5" >
  190.               </TD>
  191.             </TR>
  192.             <TR>
  193.               <TD align=right height=30>分类:</TD>
  194.               <TD><select name=code>
  195.                 <option value="" selected>所有图书</option>
  196.                 <%
  197. set rs=server.CreateObject("adodb.recordset")
  198. rs.open "select * from category",conn,1,1
  199. do while not rs.eof
  200. %>
  201.                 <option value="<%=rs("categoryid")%>" ><%=rs("category")%></option>
  202.                 <%
  203. rs.movenext
  204. loop
  205. rs.close
  206. set rs=nothing
  207. %>
  208.               </select></TD>
  209.             </TR>
  210.             <TR>
  211.               <TD align=right height=30>排序字段:</TD>
  212.               <TD><input name="OrderField" type="radio" value="adddate" checked>
  213.                 添加日期&nbsp;                  <input type="radio" name="OrderField" value="productdate">
  214.                   出版日期
  215.                   <input type="radio" name="OrderField" value="price2">
  216.                   价钱(会员价)
  217.                   <br>
  218.                   <br>                  <input type="radio" name="OrderField" value="vipprice">
  219. 价钱(VIP)
  220. <input type="radio" name="OrderField" value="pagenum">
  221. 页数&nbsp;&nbsp;&nbsp;&nbsp;<input type="radio" name="OrderField" value="discount">
  222. 折扣</TD>
  223.             </TR>
  224.             <TR>
  225.               <TD align=right width="31%" height=30>排序方式:</TD>
  226.               <TD width="69%"><input type="radio" name="Order" value="ASC"> 
  227.                 升序
  228.                   <input name="Order" type="radio" value="DESC" checked>
  229.               降序</TD>
  230.             </TR>
  231.             <TR align=center>
  232.               <TD height=40 colSpan=2><INPUT type=submit value=开始搜索 name=Submit2 onClick="return search()">              </TD>
  233.             </TR>
  234.           
  235.       </TABLE>
  236.     </FORM></td>
  237.   </tr>
  238. </table>
  239. <!--#include file="foot.htm"-->
  240. </body>
  241. </html>