ASP+Access使用select后怎么自动刷新页面
我正在设计一个学生管理系统。需要实现的是在我用select选择一个班级后,在第2个select选择学号后,在页面下方自动更新出此学生的各种信息,并且能用INPUT进行更新...
我正在设计一个学生管理系统。
需要实现的是在我用select选择一个班级后,在第2个select选择学号后,在页面下方自动更新出此学生的各种信息,并且能用INPUT进行更新。现在能实现选班级后自动更新相关学号,但怎么更新出地址一类的我就不会了。
数据库是ACCESS的,CLASS为班级和学号对应表,NCLASS为学号和学生各种信息对应表。
现编好的如下:
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from Nclass order by Nclass_id asc"
rs.open sql,conn,1,1
%>
<SCRIPT language=JavaScript src="../include/addNews.js"></SCRIPT>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Nclass_name"))%>","<%= trim(rs("class_id"))%>","<%= trim(rs("Nclass_id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.addform.Nclass_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.addform.Nclass_id.options[document.addform.Nclass_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function showit()
{
showa.innerHTML=A0103.value;
showb.innerHTML=A0103.value;
showc.innerHTML=A0103.value;
}
</script>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from class where fatherID=1",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="class_id" onChange="changelocation(document.addform.class_id.options[document.addform.class_id.selectedIndex].value)" size="1">
<option selected value="<%=rs("class_id")%>"><%=rs("class_name")%></option>
<%
dim selclass
selclass=rs("class_id")
rs.movenext
do while not rs.eof
%>
<option value='<%=rs("class_id")%>'><%=rs("class_name")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="Nclass_id">
<%
sql="select * from Nclass where class_ID='"&selclass&"'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("Nclass_ID")%>"><%=rs("Nclass_name")%></option>
<%
dim selway
selway=rs("Nclass_id")
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("Nclass_ID")%>"><%=rs("Nclass_name")%></option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
</select>
不能更新整个页面,只能在相关的地方更新出姓名,地址,通讯方式等内容,并且这些内容需处于可修改状态。 展开
需要实现的是在我用select选择一个班级后,在第2个select选择学号后,在页面下方自动更新出此学生的各种信息,并且能用INPUT进行更新。现在能实现选班级后自动更新相关学号,但怎么更新出地址一类的我就不会了。
数据库是ACCESS的,CLASS为班级和学号对应表,NCLASS为学号和学生各种信息对应表。
现编好的如下:
<%
dim rs
dim sql
dim count
set rs=server.createobject("adodb.recordset")
sql = "select * from Nclass order by Nclass_id asc"
rs.open sql,conn,1,1
%>
<SCRIPT language=JavaScript src="../include/addNews.js"></SCRIPT>
<script language = "JavaScript">
var onecount;
onecount=0;
subcat = new Array();
<%
count = 0
do while not rs.eof
%>
subcat[<%=count%>] = new Array("<%= trim(rs("Nclass_name"))%>","<%= trim(rs("class_id"))%>","<%= trim(rs("Nclass_id"))%>");
<%
count = count + 1
rs.movenext
loop
rs.close
%>
onecount=<%=count%>;
function changelocation(locationid)
{
document.addform.Nclass_id.length = 0;
var locationid=locationid;
var i;
for (i=0;i < onecount; i++)
{
if (subcat[i][1] == locationid)
{
document.addform.Nclass_id.options[document.addform.Nclass_id.length] = new Option(subcat[i][0], subcat[i][2]);
}
}
}
function showit()
{
showa.innerHTML=A0103.value;
showb.innerHTML=A0103.value;
showc.innerHTML=A0103.value;
}
</script>
<%
set rs=server.createobject("adodb.recordset")
rs.open "select * from class where fatherID=1",conn,1,1
if rs.eof and rs.bof then
response.write "请先添加栏目。"
response.end
else
%>
<select name="class_id" onChange="changelocation(document.addform.class_id.options[document.addform.class_id.selectedIndex].value)" size="1">
<option selected value="<%=rs("class_id")%>"><%=rs("class_name")%></option>
<%
dim selclass
selclass=rs("class_id")
rs.movenext
do while not rs.eof
%>
<option value='<%=rs("class_id")%>'><%=rs("class_name")%></option>
<%
rs.movenext
loop
end if
rs.close
%>
</select>
<select name="Nclass_id">
<%
sql="select * from Nclass where class_ID='"&selclass&"'"
rs.open sql,conn,1,1
if not(rs.eof and rs.bof) then
%>
<option selected value="<%=rs("Nclass_ID")%>"><%=rs("Nclass_name")%></option>
<%
dim selway
selway=rs("Nclass_id")
rs.movenext
do while not rs.eof
%>
<option value="<%=rs("Nclass_ID")%>"><%=rs("Nclass_name")%></option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
%>
</select>
不能更新整个页面,只能在相关的地方更新出姓名,地址,通讯方式等内容,并且这些内容需处于可修改状态。 展开
2个回答
展开全部
option value="<%=rs("Nclass_ID")%>"><%=rs("Nclass_name")%></option>
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
response.write"<script>location.reload()</script>"
%>
这样应该行了
</select>
---------------------------------
用iframe
把姓名,地址,通讯方式等内容放进里边。让姓名,地址,通讯方式等内容这个内容的页面更新就行了。
<%
rs.movenext
loop
end if
rs.close
set rs = nothing
conn.Close
set conn = nothing
response.write"<script>location.reload()</script>"
%>
这样应该行了
</select>
---------------------------------
用iframe
把姓名,地址,通讯方式等内容放进里边。让姓名,地址,通讯方式等内容这个内容的页面更新就行了。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询