当我进入一个页面时点击广东的时候就在同一个页面出现广东的数据,怎样将数据传回同一个页面
当我进入一个页面时点击广东的时候就在同一个页面出现广东的数据,怎样将数据传回同一个页面
用一个回传变量进行判断读取就可以
比如网页文件名为
<html>
<script language=JavaScript>
function City_Click(CName)
{
document.HidForm.HVal.value=CName;
document.HidForm.submit();
}
</script>
<a href=TMP4zs4j2peyy.asp >ABC</a>
<%
IF Request.Form("HVal")<>"" Then
Response.Write "这里的内容第一次打开看不到,点击连接并提交网页察看"
End IF
%>
<form name=HidForm action=TMP4zs4j2peyy.asp method=post >
<input type=hidden name=HVal >
</form>
</html>
首先在<head></head>标签内添加如下JavaScript代码
<script language=JavaScript>
function City_Click(CName)
{
document.SelCity.Hval.value=CName;
document.SelCity.submit();
}
</script>
然后在表单的地方照如下方法修改
<form name=SelCity method="post" action="forwork.asp%>">
在城市循环中把
response.write "<td width='14%' align='center'><a href=forwork.asp?city=" & replace(rs("city")," "," ") & ">" & rs("city") & "</a></td>"
修改为这个样子
response.write "<td width='14%' align='center'><a href=# onClick=City_Click('" & replace(rs("city")," "," ")&"'); >"& rs("city") & "</a></td>"
<%
'将接收省份条件的所有代码都包括在
'IF Request.Form("Hval")<>"" Then...End IF语句块内
IF Request.Form("Hval")<>"" Then
dim rs2,sql2
Set rs2 = Server.CreateObject("ADODB.Recordset")
sql2="select * from trade Where Province='" & replace(request.form("Hval")," ","") & "'" '本人想在这里实现接收,以省份为条件作为选择数据Province为数据库中的字段.,但是以二楼讲的都收不到数据
rs2.open sql2,conn,1,1
dim j
response.Write"<table width='750' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B0B0B0' >"
response.Write"<tr><td bgcolor='#FFFFFF'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' >"
do while not rs2.eof
j=j+1
response.write "<td width='14%' align='center'><a href='forwork.asp'>" & rs2("ComName") & "</a></td>"
if j mod 7 =0 then
response.write "<tr></tr>"
end if
rs2.movenext
loop
response.Write("</td></tr>")
response.Write("</table>")
response.Write("</table>")
End IF
%>
<%
if request("city")="" then
call menu()
else
call view()
end if
function menu()
dim rs,sql
Set rs = Server.CreateObject("ADODB.Recordset")
sql="select * from City"
rs.open sql,conn,1,1
dim i
response.Write"<table width='750' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B0B0B0' >"
response.Write"<tr><td bgcolor='#FFFFFF'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' >"
response.Write("<tr width='100%' align='center'>国内品牌</tr>")
do while not rs.eof
i=i+1
response.write "<td width='14%' align='center'>"
%>
<span onclick="makeRequest('forwork.asp?city="<%=(rs("city")%>','list')"><%=(rs("city")%></font></span>
<%
response.write "</a></td>"
if i mod 7 =0 then
response.write "<tr></tr>"
end if
rs.movenext
loop
response.Write("</td><td><div id=list></div><td></tr>")
response.Write("</table>")
response.Write("</table>")
response.write("<input type=hidden name=Hval>")
end function
%>
<%
function view()
dim rs2,sql2
Set rs2 = Server.CreateObject("ADODB.Recordset")
sql2="select * from trade Where Province='" & replace(request("city")," ","") & "'" '本人想在这里实现接收,以省份为条件作为选择数据Province为数据库中的字段.,但是以二楼讲的都收不到数据
rs2.open sql2,conn,1,1
dim j
response.Write"<table width='750' border='0' align='center' cellpadding='5' cellspacing='1' bgcolor='#B0B0B0' >"
response.Write"<tr><td bgcolor='#FFFFFF'><table width='100%' border='0' align='center' cellpadding='0' cellspacing='0' >"
do while not rs2.eof
j=j+1
response.write "<td width='14%' align='center'><a href='forwork.asp'>" & rs2("ComName") & "</a></td>"
if j mod 7 =0 then
response.write "<tr></tr>"
end if
rs2.movenext
loop
response.Write("</td></tr>")
response.Write("</table>")
response.Write("</table>")
end function
%>
<script language="javascript">
var http_request = false;
function creathttp_request(){
http_request = false;
if (window.ActiveXObject) {
try {
http_request = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
http_request = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e) {}
}
}
if (!http_request) {
alert('Giving up :( Cannot create an XMLHTTP instance');
return false;
}
}
function makeRequest(url,obj)
{
creathttp_request();
http_request.onreadystatechange = alertContents;
http_request.open('GET', url, true);
http_request.send(null);
function alertContents() {
document.getElementById(obj).innerHTML="<font size=2>正在加载数据,请稍候...</font>";
if (http_request.readyState == 4) {
if (http_request.status == 200) {
document.getElementById(obj).innerHTML=http_request.responseText;
} else {
alert('There was a problem with the request.');
}
}
}
}
</script>