| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 539 人关注过本帖
标题:请求解决一个问题~急
只看楼主 加入收藏
kkandkkg
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-7-20
收藏
 问题点数:0 回复次数:6 
请求解决一个问题~急
本人想在同一个页面实现不同数据的转换如下图:
图片附件: 游客没有浏览图片的权限,请 登录注册


当我进入一个页面时点击广东的时候就在同一个页面出现广东的数据,怎样将数据传回同一个页面

图片附件: 游客没有浏览图片的权限,请 登录注册

搜索更多相关主题的帖子: 请求 
2006-07-20 21:39
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 

用一个回传变量进行判断读取就可以
比如网页文件名为
<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>

2006-07-20 22:22
kkandkkg
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-7-20
收藏
得分:0 
代码如下:
<form method="post" action="forwork.asp%>">
<%
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'><a href=forwork.asp?city=" & replace(rs("city")," ","&nbsp;") & ">" & rs("city") & "</a></td>"
if i mod 7 =0 then
response.write "<tr></tr>"
end if
rs.movenext
loop
response.Write("</td></tr>")
response.Write("</table>")
response.Write("</table>")
response.write("<input type=hidden name=Hval>")
%>
</form>
<%
dim rs2,sql2
Set rs2 = Server.CreateObject("ADODB.Recordset")
sql2="select * from trade Where Province='" & replace(request.form("Hval"),"&nbsp;","") & "'" '本人想在这里实现接收,以省份为条件作为选择数据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>")
%>
上面是一个在数据表读取省份~但是怎样才能实现原页面接收点击的省份数据
2006-07-20 23:37
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
收藏
得分:0 

首先在<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")," ","&nbsp;") & ">" & rs("city") & "</a></td>"
修改为这个样子
response.write "<td width='14%' align='center'><a href=# onClick=City_Click('" & replace(rs("city")," ","&nbsp;")&"'); >"& 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"),"&nbsp;","") & "'" '本人想在这里实现接收,以省份为条件作为选择数据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
%>


2006-07-21 08:20
icecool
Rank: 9Rank: 9Rank: 9
等 级:贵宾
威 望:20
帖 子:1216
专家分:1376
注 册:2005-3-14
收藏
得分:0 

<%
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"),"&nbsp;","") & "'" '本人想在这里实现接收,以省份为条件作为选择数据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>


http://toorup.3v.do
loading...
2006-07-21 08:57
kkandkkg
Rank: 1
等 级:新手上路
帖 子:18
专家分:0
注 册:2006-7-20
收藏
得分:0 
谢谢~!本人已经解决了~
2006-07-21 12:27
huyuntao
Rank: 1
等 级:新手上路
帖 子:44
专家分:0
注 册:2006-6-15
收藏
得分:0 
这代码发的,一个比一个长
2006-07-21 17:24
快速回复:请求解决一个问题~急
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.048985 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved