注册 登录
编程论坛 ASP技术论坛

asp如何实现同一页面的多个提交按钮提交不同的sql语句,实现在同一页面显示不同的查询结果

lukebc 发布于 2016-09-28 15:17, 3090 次点击
我的代码是这样的,但好像不行

<form method="post" action="jccx.asp"name="form1">
    <tr>
      <td colspan="6" align="center" bgcolor="#609B95"><div align="center"><strong>进 仓 查 询</strong></div></td>
  </tr>
  <p align="center">
  <tr>
    <td width="100"><div align="center">进 仓 编 号</div></td>
  </tr>
 <td><div align="center">
   <input name="jcbh" class="wzjz" type="text" size="20" onFocus="this.value=''">
 </div></td>
 <div align="center">
   </tr>
   <br>
   <br>

</div>
 <td><div align="center">
   <input type="submit" name="soc" value="S O 查 询">
   <input type="submit" name="pdc" value="浦 东 当 日 查 询">
   <input type="submit" name="ysc" value="洋 山 当 日 查 询">
   </form>
 </div></td>
 <div align="center">
   </tr>
   
 </div>
 <%
dim i,intPage,page,pre,last,filepath
if request("soc")="S O 查 询" then
if request("jcbh")<>""then
if cond="" then
cond="进仓编号 like '%" & trim(request("jcbh")) & "%'"
end if
end if
if cond<>""then
sql="select  distinct(进仓编号),仓库 from  ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键 where " & cond
end if
if request("pdc")="浦 东 当 日 查 询" then
sql="select  distinct(进仓编号),仓库 from  ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键 and CONVERT(varchar(100), 进仓时间, 23)=CONVERT(varchar(100), GETDATE(), 23) and 仓库='浦东'order by 进仓编号"
end if
if request("ysc")="洋 山 当 日 查 询" then
sql="select  distinct(进仓编号),仓库 from  ck_进仓主表 zb inner join ck_进仓明细 mx on zb.进仓主键=mx.进仓主键 and CONVERT(varchar(100), 进仓时间, 23)=CONVERT(varchar(100), GETDATE(), 23) and 仓库='洋山'order by 进仓编号"
end if
session("sql")=(sql)
2 回复
#2
hu9jj2016-10-06 19:40
在同一个页面显示时代码复杂、调试比较麻烦,还不如用不同页面显示更简单些。
#3
ke爱的小tu子2021-02-17 02:38
搞这么多代码,还不如截图来得生动形象。功能一点都不难。对了,你的代码逻辑混乱得一批。给你说,为了逻辑清晰,先接收,然后再判断。
1