asp下拉菜单
%><%add=request("add")ifadd=1thentitle=request("title")content=request("content")sele...
%>
<%
add=request("add")
if add=1 then
title=request("title")
content=request("content")
selectstr=request("select")
'Response.write selectstr
'Response.end
set rs=server.CreateObject("adodb.recordset")
sql="select * from NewsTable"
rs.open sql,conn,1,3
rs.addnew
rs("news_title")=title
rs("news_content")=content
rs("news_time")=now
rs("sort_id") =selectstr
rs.update
rs.close
response.Write"<script>alert(""添加成功"");location.href='newsadd.asp'</script>"
response.end()
end if
%>
<%
if session("admin")="" then
Response.write "<script>alert('请登陆');location.href='admin.asp'</script>"
Response.end
end if
Response.write session("admin")&"你好,欢迎您登陆!"
%><style type="text/css">
<!--
body,td,th {
color: #FF0000;
}
body {
background-image: url(../images/7003878_4296.jpg);
}
-->
</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #6e6e6e}
-->
</style>
<form action="?add=1" method="post">
<div align="left">
<table width="209" border="0">
<tr>
<td width="149"> </td>
</tr>
</table>
</div>
<table width="770" height="283" align="center">
<tr>
<td width="12%" height="86">
<div align="center">最新公告:</div></td>
<td width="88%" colspan="2"><input type="text" name="title" style="height=25px">
<label>
<select name="select">
<%
sql="select * from SortTable"
set rs1=conn.execute(sql)
if not (rs1.eof and rs1.bof) Then
do while not rs1.eof
response.write "<option value="""&rs1("sort_id")&""">"&rs1("sort_name")&"</option>"
rs1.movenext
loop
else
response.write "<option value=0>no data</option>"
end if
%>
</select>
我想做的就是通过下拉菜单选择我存入的标`~比如我想添加项目 那么就在下拉菜单中选择项目~提交后他存入项目表
我的数据库表有4个
存放公告NewsTable 字段news_id news_title news_content sort_id
存放项目ClassTable 字段class_id class_title class_content
存放文章SchoolTable 字段 school_id school_title school_content
存放分类SordTable 字段sorf_id sorf_name
我现在已经在NewsTable中获取到了值~接下来该怎么做???问题表示的不清楚的话我在线等 展开
<%
add=request("add")
if add=1 then
title=request("title")
content=request("content")
selectstr=request("select")
'Response.write selectstr
'Response.end
set rs=server.CreateObject("adodb.recordset")
sql="select * from NewsTable"
rs.open sql,conn,1,3
rs.addnew
rs("news_title")=title
rs("news_content")=content
rs("news_time")=now
rs("sort_id") =selectstr
rs.update
rs.close
response.Write"<script>alert(""添加成功"");location.href='newsadd.asp'</script>"
response.end()
end if
%>
<%
if session("admin")="" then
Response.write "<script>alert('请登陆');location.href='admin.asp'</script>"
Response.end
end if
Response.write session("admin")&"你好,欢迎您登陆!"
%><style type="text/css">
<!--
body,td,th {
color: #FF0000;
}
body {
background-image: url(../images/7003878_4296.jpg);
}
-->
</style>
<link href="../style.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
.STYLE1 {color: #6e6e6e}
-->
</style>
<form action="?add=1" method="post">
<div align="left">
<table width="209" border="0">
<tr>
<td width="149"> </td>
</tr>
</table>
</div>
<table width="770" height="283" align="center">
<tr>
<td width="12%" height="86">
<div align="center">最新公告:</div></td>
<td width="88%" colspan="2"><input type="text" name="title" style="height=25px">
<label>
<select name="select">
<%
sql="select * from SortTable"
set rs1=conn.execute(sql)
if not (rs1.eof and rs1.bof) Then
do while not rs1.eof
response.write "<option value="""&rs1("sort_id")&""">"&rs1("sort_name")&"</option>"
rs1.movenext
loop
else
response.write "<option value=0>no data</option>"
end if
%>
</select>
我想做的就是通过下拉菜单选择我存入的标`~比如我想添加项目 那么就在下拉菜单中选择项目~提交后他存入项目表
我的数据库表有4个
存放公告NewsTable 字段news_id news_title news_content sort_id
存放项目ClassTable 字段class_id class_title class_content
存放文章SchoolTable 字段 school_id school_title school_content
存放分类SordTable 字段sorf_id sorf_name
我现在已经在NewsTable中获取到了值~接下来该怎么做???问题表示的不清楚的话我在线等 展开
1个回答
展开全部
<%
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.MapPath("mofei.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>
<script language = "JavaScript">
sall=new Array();
<%
Dim i
i=0
set rs=conn.execute("select * from subject")
do while not rs.eof
%>
sall[<%=i%>]=new Array("<%=rs("subjectname")%>","<%=rs("departid")%>","<%=rs("subjectid")%>");
<%
i=i+1
rs.movenext
loop
rs.close
%>
function changeselect(selvalue)
{
document.myform.Nclassid.length=0;
var selvalue=selvalue;
var i;
for(i=0;i<sall.length;i++)
{
if(sall[1]==selvalue)
{
var newOption1=new Option(sall[0],sall[2]);
document.all.Nclassid.add(newOption1);
}
}
}
</script>
<form method="post" name="myform" action="ru_query.asp">
<select name="classid" onChange="changeselect(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option selected value="">省</option>
<%
set rs1=conn.execute("select * from depart")
do while not rs1.eof
response.write "<option value='"&rs1("departid")&"'>"&rs1("departname")&"</option>"&chr(13)+chr(10)
rs1.movenext
loop
rs1.close
%>
</select>
<select name="Nclassid">
<option selected value="">市</option>
</select>
dim conn
dim connstr
on error resume next
connstr="DBQ="+server.MapPath("mofei.mdb")+";DefaultDir=;DRIVER={Microsoft Access Driver (*.mdb)};"
set conn=server.CreateObject("ADODB.CONNECTION")
conn.open connstr
%>
<script language = "JavaScript">
sall=new Array();
<%
Dim i
i=0
set rs=conn.execute("select * from subject")
do while not rs.eof
%>
sall[<%=i%>]=new Array("<%=rs("subjectname")%>","<%=rs("departid")%>","<%=rs("subjectid")%>");
<%
i=i+1
rs.movenext
loop
rs.close
%>
function changeselect(selvalue)
{
document.myform.Nclassid.length=0;
var selvalue=selvalue;
var i;
for(i=0;i<sall.length;i++)
{
if(sall[1]==selvalue)
{
var newOption1=new Option(sall[0],sall[2]);
document.all.Nclassid.add(newOption1);
}
}
}
</script>
<form method="post" name="myform" action="ru_query.asp">
<select name="classid" onChange="changeselect(document.myform.classid.options[document.myform.classid.selectedIndex].value)" size="1">
<option selected value="">省</option>
<%
set rs1=conn.execute("select * from depart")
do while not rs1.eof
response.write "<option value='"&rs1("departid")&"'>"&rs1("departname")&"</option>"&chr(13)+chr(10)
rs1.movenext
loop
rs1.close
%>
</select>
<select name="Nclassid">
<option selected value="">市</option>
</select>
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询