楼上的闭嘴..
面朝大海,春暖花开!
<!--#include file=conn.asp-->
<script language="javascript">
<!--
function se_test()
{
document.form1.submit(); //自动提交表单
}
-->
</script>
<div align="center">
<%
if Request.Form("submit")="提交" then '如果点击了提交安纽
if Request.Form("neirong")<>"" then '如果内容文本不为空则可以添加
if Request.Form("radiobutton")="fir" then '如果选择的是向大类中添加
sql="select top 1 * from firsts order by fir_grades desc" '向大类的表格中添加,选择最大的等级
set rs=conn.execute(sql)
fir_grades=rs("fir_grades")+1 '新添加的等级是现有最大等级加1
sql="insert into firsts(firsts,fir_grades) values('"&Request.Form("neirong")&"',"&fir_grades&")"
conn.execute(sql)
else '如果选择的是向小类中添加
sql="insert into seconds(seconds,se_grades) values('"&Request.Form("neirong")&"',"&Request.Form("firsts")&")"
'小项的等级是现有所选择的大类的等级
conn.execute(sql)
end if
end if
end if
%>
<table width="600" border="0">
<form name=form1 action="add.asp" method=post>
<tr>
<td width="94">一级:</td>
<td width="191"><select name="firsts" onChange="se_test()"> <!--当选项发生改变的时候,触发自动提交选项,用来改变小项的值,做到大项与小项的对应-->
<%
sql1="select * from firsts"
set rs1=conn.execute(sql1)
if not (rs1.eof and rs1.bof) then
do while not rs1.eof
if rs1("fir_grades")=cint(Request.Form("firsts")) then '如果数据库中的记录集和FROM提交的下拉列表的值一样,则这个记录在网站加载的时候被选中
%>
<option value="<%=rs1("fir_grades")%>" selected><%=rs1("firsts")%></option>
<%
else
%>
<option value="<%=rs1("fir_grades")%>"><%=rs1("firsts")%></option> <!--否则这记录不被选中-->
<%
end if
rs1.movenext
loop
end if
%>
</select></td>
<td width="83">二级:</td>
<td><select name="seconds">
<%
if Request.Form("firsts")<>"" then '如果一级记录改变了,则根据一级记录的值查询二级记录
sql2="select * from seconds where se_grades="&Request.Form("firsts")
else
sql2="select * from seconds where se_grades=1" '如果一级记录没有被提交,则选中默认的第一条
end if
set rs2=conn.execute(sql2)
if not (rs2.eof and rs2.bof) then
do while not rs2.eof
%>
<option value="<%=rs2("se_grades")%>"><%=rs2("seconds")%></option> <!--列出二级目录的值-->
<%
rs2.movenext
loop
end if
%>
</select></td>
</tr>
<tr>
<td>添加:</td>
<td><input name="neirong" type="text" id="neirong"></td>
<td>属于:</td>
<td><input name="radiobutton" type="radio" value="fir" checked>
一级
<input type="radio" name="radiobutton" value="se">
二级</td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="Submit" value="提交"></td>
<td> </td>
<td><input name="reset" type="reset" id="reset" value="重置"></td>
</tr>
</form>
</table>
</div>
<%
dim count
set rs=server.createobject("adodb.recordset")
rs.open "select * from sorts order by sortsorder ",conn,1,1%>//sorts是小类的表..
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("sorts"))%>","<%= rs("categoryid")%>","<%= rs("sortsid")%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.myform.sortsid.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.myform.sortsid.options[document.myform.sortsid.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
这个我弄不懂..怎么要这取值呀..
[此贴子已经被作者于2006-3-30 14:29:30编辑过]