select * from eptime_zhanghu where id=6怎样把6换成变量

gulongcun 2016-04-13 09:51:35
select * from eptime_zhanghu where id=6怎样把6换成变量。
也就是在Eptime_zhanghu表中选择部门后,预算金额在Eptime_zhanghu表中就自动填入预算金额表单中,且无法修改。以上代码运行正常,就是sql="select * from eptime_zhanghu where id=6"这句,不知道怎么才能实现选择部门后,查询到该部门id的记录。代码如下:
<td align="right" height="30">部门名称:</td>
<td class="category">
<%
sql="select * from Eptime_zhanghu order by id"
set rs_zhanghu=conn.execute(sql)
if rs_zhanghu.eof then
%>
<script language="javascript">
alert("请先添加部门!")
window.location.href="zhanghu_add.asp"
</script>
<%
response.end
else
%>
<select name="zhanghu" style="width:200px">
<%
do while rs_zhanghu.eof=false
%>
<option value="<%=rs_zhanghu("id")%>"<%if rs_zhanghu("id")=CInt(request.Cookies("zhanghu")) then%> selected="selected"<%end if%>><
%=rs_zhanghu("name")%></option>
<%
rs_zhanghu.movenext
loop
%>
</select>
<%
end if
%><font color="#ff0000">*</font></td>
</tr>
<input type="hidden" name="id" value="<%=nowid%>">
<%
sql="select * from eptime_zhanghu where id=6"
set rs_yusuan=conn.execute(sql)
if rs_yusuan.eof then%>
<script language="javascript">
alert("没有查询到相关数据!")
window.location.href="zhanghu_add.asp"
</script><%
end if
%>
<tr>
<td align="right" height="30">预算金额:</td>
<td class="category"><input type="text" name="price" value="<%=rs_yusuan("yusuan")%>" disabled="true" style="width:200px"
onKeyUp="value=value.replace(/[^\d.]/g,'')">
<font color="#666666">元</font>
<font color="#ff0000">*</font>(其中部门人数为<%=rs_yusuan("amount")%>人,预算标准为<%=rs_yusuan("type")%>元。)
</td>
...全文
228 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gulongcun 2016-04-13
  • 打赏
  • 举报
回复
id的值是由前面的选择决定的
gulongcun 2016-04-13
  • 打赏
  • 举报
回复
id的值是由前面的选择决定的,好像是由这里 <option value="<%=rs_zhanghu("id")%>"<%if rs_zhanghu("id")=CInt(request.Cookies("zhanghu")) then%> selected="selected"<%end if%>>< %=rs_zhanghu("name")%></option>,但是我不知道怎样才能得到这个id
gulongcun 2016-04-13
  • 打赏
  • 举报
回复
好像不行,我这样, <input type="hidden" name="id" value="<%=nowid%>"> <% sql="select * from eptime_zhanghu where id="nowid 还是不行
  • 打赏
  • 举报
回复
<select name="zhanghu" style="width:200px" onchange="location='?zhid='+this.value">

zhid=request.querystring("zhid")&""
if not isnumeric(zhid) then zhid="6"''如果不是数字默认一个id
sql="select * from eptime_zhanghu where id="&zhid
php_wsd 2016-04-13
  • 打赏
  • 举报
回复
id = 6 sql="select * from eptime_zhanghu where id="&id
gulongcun 2016-04-13
  • 打赏
  • 举报
回复
上图中,选择四川省财政厅的话,预算金额就从表eptime_zhanghu中查出,填入于是金额中,如果选择其他部门,也从eptime_zhanghu中查出填入于是金额中,以此类推。现在用的是常数。剩下的代码如下 <tr> <td width="20%" height="30" align="right">类型:</td> <td width="80%" class="category"> <select name="type" onChange="form1.submit()" style="width:200px"> <option value="0"<%if nowtype="0" then%> selected="selected"<%end if%>>收入</option> </select> <font color="#ff0000">*</font></td> </tr> </form> <form name="form2"> <input type="hidden" name="type" value="<%=nowtype%>"> <tr> <td align="right" height="30">所属科目大类:</td> <td class="category"> <% sql="select * from Eptime_money_bigclass where type="&nowtype&" order by id" set rs_bigclass=conn.execute(sql) if rs_bigclass.eof then %> <script language="javascript"> alert("请先添加科目大类!") window.location.href="bigclass_add.asp?type=<%=nowtype%>" </script> <% response.end end if nowbigclass=request("bigclass") if nowbigclass="" then nowbigclass=rs_bigclass("id") end if %> <select name="bigclass" onChange="form2.submit()" style="width:200px"> <% do while rs_bigclass.eof=false %> <option value="<%=rs_bigclass("id")%>"<%if trim(cstr(rs_bigclass("id")))=nowbigclass then%> selected="selected"<%end if%> ><%=rs_bigclass("bigclass")%><font color="#ff0000"></font></option> <% rs_bigclass.movenext loop %> </select> <font color="#ff0000">*</font></td> </tr> </form> <form name="form3"> <input type="hidden" name="bigclass" value="<%=nowbigclass%>"> <input type="hidden" name="type" value="<%=nowtype%>"> <tr> <td align="right" height="30">所属科目小类:</td> <td class="category"> <% sql="select * from Eptime_money_smallclass where id_bigclass="&nowbigclass&" order by id" set rs_smallclass=conn.execute(sql) %> <select name="smallclass" style="width:200px"> <% do while rs_smallclass.eof=false %> <option value="<%=rs_smallclass("id")%>"<%if trim(cstr(rs_smallclass("id")))=nowsmallclass then%> selected="selected"<%end if%>><%=rs_smallclass("smallclass")%><font color="#ff0000"></font></option> <% rs_smallclass.movenext loop %> </select> <font color="#ff0000">*</font></td> </tr> </tr> </form> <form name="form4"> <tr> <td align="right" height="30">部门名称:</td> <td class="category"> <% sql="select * from Eptime_zhanghu order by id" set rs_zhanghu=conn.execute(sql) if rs_zhanghu.eof then %> <script language="javascript"> alert("请先添加部门!") window.location.href="zhanghu_add.asp" </script> <% response.end else %> <select name="name" style="width:200px"> <% do while rs_zhanghu.eof=false %> <option value="<%=rs_zhanghu("id")%>"<%if rs_zhanghu("id")=CInt(request.Cookies("zhanghu")) then%> selected="selected"<%end if%>><%=rs_zhanghu("name")%></option> <% rs_zhanghu.movenext loop %> </select> <% end if id=request("name") sql="select * from Eptime_zhanghu where id=6" set rs_yusuan=conn.execute(sql) %> <font color="#ff0000">*</font></td> </tr> <tr> <td align="right" height="30">预算金额:</td> <td class="category"><input type="text" name="price" value="<%=rs_yusuan("yusuan")%>" disabled="true" style="width:200px" onKeyUp="value=value.replace(/[^\d.]/g,'')" onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d.]/g,''))"> <font color="#666666">元</font> <font color="#ff0000">*</font>(其中部门人数为<%=rs_yusuan("amount")%>人,预算标准为<%=rs_yusuan("type")%>元。) </td> </tr> </form> <tr> <td align="right" height="30">业务项目:</td> <td class="category"> <% sql="select * from Eptime_xiangmu order by id" set rs_xiangmu=conn.execute(sql) if rs_xiangmu.eof then %> <script language="javascript"> alert("请先添加项目!") window.location.href="xiangmu_add.asp" </script> <% response.end else %> <select name="xiangmu" style="width:200px"> <% do while rs_xiangmu.eof=false %><option value="">请选择业务项目</option> <option value="<%=rs_xiangmu("id")%>"<%if rs_xiangmu("id")=CInt(request.Cookies("xiangmu")) then%> selected="selected"<%end if%>><%=rs_xiangmu("name")%></option> <% rs_xiangmu.movenext loop %> </select> <% end if %> </td> </tr> <tr> <td align="right" height="30">往来单位:</td> <td class="category"> <% sql="select * from Eptime_wanglai order by id" set rs_wanglai=conn.execute(sql) if rs_wanglai.eof then %> <script language="javascript"> alert("请先添加生往来单位!") window.location.href="wanglai_add.asp" </script> <% response.end else %> <select name="wanglai" style="width:200px"> <option value="">请选择往来单位</option> <% do while rs_wanglai.eof=false %> <option value="<%=rs_wanglai("id")%>"<%if rs_wanglai("id")=CInt(request.Cookies("wanglai")) then%> selected="selected"<%end if%>><%=rs_wanglai("name")%></option> <% rs_wanglai.movenext loop %> </select> <% end if %> </td> </tr> <tr> <td align="right" height="30">经 办 人:</td> <td class="category"> <% sql="select * from Eptime_yuangong order by id" set rs_yuangong=conn.execute(sql) if rs_yuangong.eof then %> <script language="javascript"> alert("请先添加员工(经办人)!") window.location.href="yuangong_add.asp" </script> <% response.end else %> <select name="yuangong" style="width:200px"> <% do while rs_yuangong.eof=false %> <option value="<%=rs_yuangong("id")%>"<%if rs_yuangong("id")=CInt(request.Cookies("yuangong")) then%> selected="selected"<%end if%>><%=rs_yuangong("name")%></option> <% rs_yuangong.movenext loop %> </select> <% end if %><font color="#ff0000">*</font></td> </tr> <tr> <td align="right" height="30">预算时间:</td> <td class="category"> <input name="selldate" value="<%=date()%>" style="width:200px" onFocus="this.select();document.form3.value='';" onClick="calendar();" title="单击选择日期"> </td> </tr> <tr> <td align="right" height="30">说明:</td> <td class="category"> <textarea name="beizhu" cols="60" rows="3"></textarea> </td> </tr> <tr> <td height="30"> </td> <td class="category"> <input type="hidden" name="moneyID" value="<%=moneyID%>"> <input type="hidden" name="id_login" value="<%=request.Cookies("UserID")%>"> <input type="submit" value=" 确认添加 " onClick="return check()" class="button">     <input type="hidden" name="hid2" value="ok"> <input type="reset" value=" 重新填写 " class="button"> <input type="button" value=" 放弃修改返回 " onClick="window.history.go(-1)" class="button"> </td> </tr> </form> </table> </td> <td></td> </tr> <tr> <td><img src="images/r_4.gif" alt="" /></td> <td></td> <td><img src="images/r_3.gif" alt="" /></td> </tr> </table> </body> </html>
gulongcun 2016-04-13
  • 打赏
  • 举报
回复

完整的代码为,红色是要改的:
<!-- #include file="conn.asp" -->
<html>
<head>
<title><%=sitename%>-年初预算录入</title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<script language=javascript src="js/calendar.js"></script>
<link href="images/admin.css" rel="stylesheet" type="text/css">
<style>
body {
background-color:#FFFFFF;
}
</style>
</HEAD>
<BODY>
<%
if request("hid2")<>"" then
nowselldate=request("selldate")
nowtype=request("type")
nowbigclass=request("bigclass")
nowsmallclass=request("smallclass")
nowprice=request("price")
if nowprice="" then
nowprice=0
end if
nowbeizhu=request("beizhu")
nowzhanghu=request("zhanghu")
nowxiangmu=request("xiangmu")
nowyuangong=request("yuangong")
nowwanglai=request("wanglai")
nowid_login=request("id_login")
nowmoneyID=request("moneyID")

sql="select * from Eptime_money where moneyID='"&nowmoneyID&"'"
set rs=conn.execute(sql)
if rs.eof=false then
%>
<script language="javascript">
alert("单据号出错,请重新提交!")
window.location.href="money_add.asp"
</script>
<%
response.end
end if
set rs_login=conn.execute("select * from Eptime_admin where id="&nowid_login)
If(databaseType=0) Then
sql="insert into Eptime_money(id_bigclass,zhanghu,xiangmu,yuangong,wanglai,moneyID,id_smallclass,type,price,beizhu,id_login,login,selldate) values("&nowbigclass&","&nowzhanghu&","&nowxiangmu&","&nowyuangong&","&nowwanglai&",'"&nowmoneyID&"',"&nowsmallclass&","&nowtype&","&nowprice&",'"&nowbeizhu&"',"&nowid_login&",'"&rs_login("username")&"',#"&nowselldate&"#)"
ElseIf(databaseType=1) Then
sql="insert into Eptime_money(id_bigclass,zhanghu,xiangmu,yuangong,wanglai,moneyID,id_smallclass,type,price,beizhu,id_login,login,selldate) values("&nowbigclass&","&nowzhanghu&","&nowxiangmu&","&nowyuangong&","&nowwanglai&",'"&nowmoneyID&"',"&nowsmallclass&","&nowtype&","&nowprice&",'"&nowbeizhu&"',"&nowid_login&",'"&rs_login("username")&"','"&nowselldate&"')"
End If
conn.execute(sql)

If nowtype="0" Then
sql="update Eptime_zhanghu set amount=amount+"&nowprice&" where id="&nowzhanghu
conn.execute(sql)
End If

If nowtype="1" Then
sql="update Eptime_zhanghu set amount=amount-"&nowprice&" where id="&nowzhanghu
conn.execute(sql)
End If
set rs_bigclass=conn.execute("select * from Eptime_money_bigclass where id="&nowbigclass)
If rs_bigclass("isok")=1 Then
function makefilename1()
if month(now()) <10 then
mont= "0"&month(now())
else
mont=month(now())
end if
if day(now()) <10 then
dat= "0"&day(now())
else
dat=day(now())
end if
makefilename1="ZJ"&year(now())&mont&dat

end function
PostID=makefilename1()
set rs1 = server.CreateObject ("adodb.recordset")
sql1="select top 1 * from Eptime_money_pay where left(moneyID,10)='"&PostID&"' order by id desc"
rs1.open sql1,conn,1,3
if not rs1.eof and not rs1.bof Then
moneyID=right(rs1("moneyID"),11)+1
moneyID="ZJ"&moneyID&""
rs1.close
set rs1=Nothing
Else
moneyID=""&PostID&"001"
End If
''If nowtype=0 Then
''nowtype1=1
''nowbeizhu1="借入款项同时产生的其它应付款"
''End If
''If nowtype=1 Then
'' nowtype1=0
'' nowbeizhu1="借出款项同时产生的其它应收款"
'' End If


sql="insert into Eptime_money_pay(id_bigclass,xiangmu,yuangong,wanglai,moneyID,id_smallclass,type,price,price1,beizhu,id_login,login,selldate,payid) values("&nowbigclass&","&nowxiangmu&","&nowyuangong&","&nowwanglai&",'"&moneyID&"',"&nowsmallclass&","&nowtype1&","&nowprice&","&nowprice&",'"&nowbeizhu1&"',"&nowid_login&",'"&rs_login("username")&"',#"&nowselldate&"#,'"&nowmoneyID&"')"
conn.execute(sql)
End If
%>
<script language="javascript">
alert("操作成功!")
window.location.href="money.asp"
</script>
<%
response.end
end if
%>
<SCRIPT language=javascript>
//-----------------------------------------------

function checkDate(strDate)
{
var result = strDate.match(/((^((1[8-9]\d{2})|([2-9]\d{3}))(-)(10|12|0?[13578])(-)(3[01]|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(11|0?[469])(-)(30|[12][0-9]|0?[1-9])$)|(^((1[8-9]\d{2})|([2-9]\d{3}))(-)(0?2)(-)(2[0-8]|1[0-9]|0?[1-9])$)|(^([2468][048]00)(-)(0?2)(-)(29)$)|(^([3579][26]00)(-)(0?2)(-)(29)$)|(^([1][89][0][48])(-)(0?2)(-)(29)$)|(^([2-9][0-9][0][48])(-)(0?2)(-)(29)$)|(^([1][89][2468][048])(-)(0?2)(-)(29)$)|(^([2-9][0-9][2468][048])(-)(0?2)(-)(29)$)|(^([1][89][13579][26])(-)(0?2)(-)(29)$)|(^([2-9][0-9][13579][26])(-)(0?2)(-)(29)$))/);
if(result==null)
{
return false;
}
return true;
}
//-----------------------------------------------

function isNumberString (InString,RefString)
{
if(InString.length==0) return (false);
for (Count=0; Count < InString.length; Count++) {
TempChar= InString.substring (Count, Count+1);
if (RefString.indexOf (TempChar, 0)==-1)
return (false);
}
return (true);
}

function check()
{

if (document.form3.smallclass.value=="")
{
alert("科目小类必须填写,此科目大类下无小类,请先添加!");
return false;
}
if (document.form3.price.value=="")
{
alert("预算金额必须填写!");
return false;
}
if (isNumberString(document.form3.price.value,"1234567890.")!=1)
{
alert("预算金额只能为数字!");
return false;
}
if (checkDate(document.form3.selldate.value)==false)
{
alert("请输入正确的日期格式!");
return false;
}
}
</script>
<%
nowtype=request("type")
if nowtype="" then nowtype=0 End If
%>
<%
function makefilename()
if month(now()) <10 then
mont= "0"&month(now())
else
mont=month(now())
end if
if day(now()) <10 then
dat= "0"&day(now())
else
dat=day(now())
end if
makefilename="NC"&year(now())&mont&dat

end function
PostID=makefilename()
set rs1 = server.CreateObject ("adodb.recordset")
sql1="select top 1 * from Eptime_money where left(moneyID,10)='"&PostID&"' order by id desc"
rs1.open sql1,conn,1,3
if not rs1.eof and not rs1.bof Then
moneyID=right(rs1("moneyID"),11)+1
moneyID="NC"&moneyID&""
rs1.close
set rs1=Nothing
Else
moneyID=""&PostID&"001"
End If
%>
<br>
<table width="95%" border="0" cellpadding="0" cellspacing="0" bgcolor="#EBEBEB" align="center">
<tr>
<td><img src="images/r_1.gif" alt="" /></td>
<td width="100%" background="images/r_0.gif">
<table cellpadding="0" cellspacing="0" width="100%">
<tr>
<td> -年初预算录入(带*号的为必填项)</td>
</tr>
</table>
</td>
<td><img src="images/r_2.gif" alt="" /></td>
</tr>
<tr>
<td></td>
<td>
<table align="center" cellpadding="4" cellspacing="1" class="toptable grid" border="1" width="95%">
<form name="form1">
<tr>
<td width="20%" height="30" align="right">单据号:</td>
<td width="80%" class="category">
<font color="#ff0000"><%=moneyID%></font></td>
</tr>
php_wsd 2016-04-13
  • 打赏
  • 举报
回复
这个下拉框的name是什么?假设是aaa id = request("aaa") sql="select * from eptime_zhanghu where id="&id

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧