asp+access联动 如何把下拉列表的值写入数据库
联动已经解决 但是写入不了数据库 提交后数据库会自动增加一列 但是是空的<!--#include file="heck.asp"--><script language="JavaScript">sall=new Array();<%dim ii=0set rs=server.CreateObject("adodb.recordset") sql="select * from khlist order by id asc" rs.open sql,conn,1,1 if not rs.eof then do until rs.eof%>sall[<%=i%>]=new Array("<%=rs("khbm")%>","<%=rs("id")%>","<%=rs("khname")%>");<%i=i+1rs.movenextloopend ifrs.closeset rs=nothing%>function changeselect(selvalue) { document.all.xl.length=0; var selvalue=selvalue; var i; for(i=0;i<sall.length;i++) { if(sall[i][0]==selvalue) { var newOption1=new Option(sall[i][2],sall[i][1]); document.all.xl.add(newOption1); } }}</script> <form action="" method=post name=form1 onSubmit="return CheckForm()"><select name="dl" ID="dl" onChange="changeselect(document.all.dl.options[document.all.dl.selectedIndex].value)"> <option>请选择</option><%set rs=server.CreateObject("adodb.recordset")sql="select * from khbm order by id asc"rs.open sql,conn,1,1do while not rs.eof%> <option value="<%=rs("id")%>"><%=rs("khtype")%></option><%rs.movenextlooprs.close%> </select> <select name="xl" ID="xl"> <option>请选择</option> </select> <tr> <td colspan="5" align="center" ><input type="submit" name="add" value=" 添 加 " /></td> </tr> </form><%If Request.form("add")=" 添 加 " ThenSet rs = Server.CreateObject("ADODB.RecordSet")Sql = "Select * From [cs]"rs.Open Sql,Conn,1,3rs.addNewrs("x1") = Request.Form("x1")rs("d1") = Request.Form("d1")rs.Updaters.CloseResponse.Write "<script>alert('操作成功!');location='javascript:history.back(-1)';</SCRIPT>"End if%>? [解决办法]rs("x1") = Request.Form("x1")rs("d1") = Request.Form("d1")您定义的变量“<select name="dl" ID="dl"”是字母"L" ,获取的是d1数字“1”
联动已经解决 但是写入不了数据库 提交后数据库会自动增加一列 但是是空的<!--#include file="heck.asp"--><script language="JavaScript">sall=new Array();<%dim ii=0set rs=server.CreateObject("adodb.recordset") sql="select * from khlist order by id asc" rs.open sql,conn,1,1 if not rs.eof then do until rs.eof%>sall[<%=i%>]=new Array("<%=rs("khbm")%>","<%=rs("id")%>","<%=rs("khname")%>");<%i=i+1rs.movenextloopend ifrs.closeset rs=nothing%>function changeselect(selvalue) { document.all.xl.length=0; var selvalue=selvalue; var i; for(i=0;i<sall.length;i++) { if(sall[i][0]==selvalue) { var newOption1=new Option(sall[i][2],sall[i][1]); document.all.xl.add(newOption1); } }}</script> <form action="" method=post name=form1 onSubmit="return CheckForm()"><select name="dl" ID="dl" onChange="changeselect(document.all.dl.options[document.all.dl.selectedIndex].value)"> <option>请选择</option><%set rs=server.CreateObject("adodb.recordset")sql="select * from khbm order by id asc"rs.open sql,conn,1,1do while not rs.eof%> <option value="<%=rs("id")%>"><%=rs("khtype")%></option><%rs.movenextlooprs.close%> </select> <select name="xl" ID="xl"> <option>请选择</option> </select> <tr> <td colspan="5" align="center" ><input type="submit" name="add" value=" 添 加 " /></td> </tr> </form><%If Request.form("add")=" 添 加 " ThenSet rs = Server.CreateObject("ADODB.RecordSet")Sql = "Select * From [cs]"rs.Open Sql,Conn,1,3rs.addNewrs("x1") = Request.Form("x1")rs("d1") = Request.Form("d1")rs.Updaters.CloseResponse.Write "<script>alert('操作成功!');location='javascript:history.back(-1)';</SCRIPT>"End if%>