到ASP版没有解决的问题.javascript与ASP之间值的问题.

hspcyeling 2008-07-11 12:16:57
<script>
function show(id) {
window.onscroll = set_height;
byid("main").style.display = "block";
byid("main").style.height = h + "px";
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.display = "block";
byid("box").style.top = (obj.scrollTop + 50) + "px";
}
</script>
<div><a href="javascript:show(1);">打开</a>

下面我如何用AJAX得到show(id)值并直接用到数据库中.

如:rs(id=show(id))
...全文
107 20 打赏 收藏 转发到动态 举报
写回复
用AI写文章
20 条回复
切换为时间正序
请发表友善的回复…
发表回复
redcn2004 2008-07-11
  • 打赏
  • 举报
回复
是不是这个意思?

<a href="javascript:show(<%=rs("id")%>);">打开 </a>
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
帮我看看啊,还是得不到ID的值?如何将那个值隐藏发送到服务器啊
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复

<!--#include file="Inc/conn.asp"-->
<LINK
href="css/main.css" type=text/css rel=stylesheet><LINK
href="css/index.css" type=text/css rel=stylesheet>
<link href="css/pic_window.css" rel="stylesheet" type="text/css">
<LINK href="css/index.css" type=text/css rel=stylesheet>


<style type="text/css">
#main{
display:none;
z-index:1000;
background-color:#000;
position:absolute;
filter:alpha(opacity=60);
-moz-opacity:0.7;
opacity: 0.7;
color:#FF570E;
margin:0;
top:0;
left:0;
width:100%;
height:auto;
text-align:center
}
#box{
display:none;
z-index:2000;
background-color:#FFF;
position:absolute;
border:1px solid #CCC;
top:10px;
left:8%;
width:860px;
height:410px;
margin:auto;
text-align:center;
font-size:12px;
color:red
}
</style>
<%%>
<script>
function byid(id){
return document.getElementById(id);
}
var obj = document.documentElement;
var w = obj.scrollWidth;
var h = window.screen.height;

function show(id) {
var a = id;
window.onscroll = set_height;
byid("main").style.display = "block";
byid("main").style.height = h + "px";
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.display = "block";
byid("box").style.top = (obj.scrollTop + 50) + "px";

return a;
}

var getID = show(id);
// ***********
// 这部分写XMLHttpRequest对象 省略。

function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("txtHint").innerHTML=xmlHttp.responseText
}
}

function GetXmlHttpObject(handler)
{

var objXmlHttp=null
if (navigator.userAgent.indexOf("Opera")>=0)
{
alert("This example doesn't work in Opera")
return;
}

if (navigator.userAgent.indexOf("MSIE")>=0)
{

var strName="Msxml2.XMLHTTP"



if (navigator.appVersion.indexOf("MSIE 5.5")>=0)

{

strName="Microsoft.XMLHTTP"

}

try

{

objXmlHttp=new ActiveXObject(strName)

objXmlHttp.onreadystatechange=handler

return objXmlHttp

}

catch(e)

{

alert("Error. Scripting for ActiveX might be disabled")

return

}

}

if (navigator.userAgent.indexOf("Mozilla")>=0)

{

objXmlHttp=new XMLHttpRequest()

objXmlHttp.onload=handler

objXmlHttp.onerror=handler

return objXmlHttp

}

}
// IE用var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");非IE用var xmlHttpReq = new XMLHttpRequest();
// ***********
// 下面关键部分

var getURL = "index.asp?ID=" + getID;

xmlHttpReq.open("GET", getURL, false); // False,此方法将会等待请求完成或者超时时才会返回, 如果是True,此方法将立即返回。
xmlHttpReq.send(); //欲通过此请求发送的数据
xmlHttpReq.responseText; //在服务器返回的值


function _close() {
byid("box").style.display = "none";
byid("main").style.display = "none";
window.onscroll = null;
}
function set_height(){
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.top = (obj.scrollTop + 50) + "px";
}
</script>


<table width="750" border="0" cellpadding="0" cellspacing="0">
<%sql="select * from photo "
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
'if rs.bof and rs.eof then
do while not rs.eof
%>
<tr>
<td width="750">

<DIV id=box_00><A style="CURSOR: hand" onClick="javascript:show(<%=rs("id")%>);"><img alt=点击查看大图 src="<%=rs("photourl")%>"
border=0></A>





</td>
</tr>
<%rs.movenext
loop
rs.close
set rs=nothing %>
</table>

<div id="main"></div>
<div id="box"><br /><br />此处为对话框文字<br /><br /><a href="javascript:_close();">确定</a>
<div>

<DIV id="close">关闭</DIV>

<DIV id="picbar">
<DIV id="pic_big"></DIV>
<DIV id="pic_small"></DIV>
</DIV>
<%
getid = Request.Form("id")
%>
<%
sql="select * from photo where id=3"
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.bof and rs.eof then
response.write "没有记录"
else
%>
<DIV id="por_title">案例:派克兰帝<%=rs("title")%> <script>
<%end if%>
<%response.write request.querystring("getid")%>
</DIV>
<DIV id="por_content">案例故事
<TEXTAREA name="textarea" rows="15" class="pic_window">导入背景: 派克兰帝是由国际投资与合作创建的专业童装及儿童用品公司。公司成立于中国童装业尚未起步的1994年,见证了国内童装品牌事业由无到有、由弱到强的10年发展史。通过全体员工的持续努力,派克兰帝成为了国内童装市场上最著名和具有号召力的童装品牌之一,并已迈进了国际市场。因为原有品牌形象已不能体现其品牌定位,派克兰帝找到了正邦为其全面更新品牌形象。 正邦策略: 正邦首先针对派克兰帝做了原有形象的分析。提出:小鱼形象略模糊,在标志构图中不够明显突出;标志内部元素主次关系不明显,主要记忆点不突出;中英文字体风格不够统一,造成识别时的混淆;标志整体略显内敛,活泼气息传达不足。 根据分析,正邦对于派克兰帝此次的标志更新,建议保留原有标志中比较形象化的构成元素——小鱼。在原有标志构成元素中,小鱼的部分是标志构成的重点。小鱼的形象已经具有一定的市场普及性与接受性。比较符合童装消费者的心理需求,易于儿童的识别与记忆。也同时能够传递出派克兰帝 Paclantic 的品牌内涵,PacLantic 是Pacific(太平洋)与Atlantic(大西洋)的合音 ,小鱼与此英文名称在含义上着紧密的联系。 品牌形象更新后,正邦又做了更加深入严格的VI规范与整合,消灭了标准字和标志组合等问题,使派克兰帝的新标志VI应用更加严谨,便于可以更好地服务于品牌形象的建设。 标志释义: 派克兰帝是由国际投资与合作创建的专业童装及儿童用品公司,标志必须简洁可信,活力大气国际化。因此标志以图形设计为主,辅以标准文字设计以强调童装及儿童用品行业特性。阐释“快乐的小鱼,缤纷的大海”的文化理念。突出派克兰帝周到服务及优良品质的品牌形象。</TEXTAREA>
</DIV>


</div>
</div>
<div><a href="javascript:show(<%'=rs("id")%>);"><img src="<%'=rs("photourl")%>" width="120" height="120" border="0"></a></div>
dh20156 2008-07-11
  • 打赏
  • 举报
回复
必須將客戶端的內容提交到服務端才可以的!
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
我的QQ:70721393
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
还是不行.要不我把程序发给你,你帮看下好不?
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
IT民工伤员在不在?
sean_xxrs 2008-07-11
  • 打赏
  • 举报
回复
在 Classic ASP 通过 Request 可以这样分别获取

<%
getid = Request.Form("id")
%>

以上用法对于 GET/POST 方式提交都是适用的。

sql="select * from photo where id="&getid

Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
response.write request.querystring("id")
为什么是这样的结果:var id=" ";
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
<%sql="select * from photo where id="&request.querystring("id")&""
这样写错误啊
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
因为我不知道下面怎么做?
<%sql="select * from photo id="
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,3
if rs.bof and rs.eof then
%>
就这个我该如何写?
yifanwu 2008-07-11
  • 打赏
  • 举报
回复
楼主这和ASP版没有解决的问题有什么关系?
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
var getURL = "http://www.battery-company.com.au/get_bran.php?id=" + getID;
能给我解释一下这句吗?
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
那我传过去之后,在ASP中如何调取了.getid吗?
sean_xxrs 2008-07-11
  • 打赏
  • 举报
回复
你的意思我明白,可以用AJAX来实现
function show(id) {
var a = id;
window.onscroll = set_height;
byid("main").style.display = "block";
byid("main").style.height = h + "px";
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.display = "block";
byid("box").style.top = (obj.scrollTop + 50) + "px";

return a;
}

var getID = show(id);

// ***********
// 这部分写XMLHttpRequest对象 省略。
// IE用var xmlHttpReq = new ActiveXObject("MSXML2.XMLHTTP.3.0");非IE用var xmlHttpReq = new XMLHttpRequest();
// ***********
// 下面关键部分

var getURL = "http://www.battery-company.com.au/get_bran.php?id=" + getID;

xmlHttpReq.open("GET", getURL, false); // False,此方法将会等待请求完成或者超时时才会返回, 如果是True,此方法将立即返回。
xmlHttpReq.send(); //欲通过此请求发送的数据
xmlHttpReq.responseText; //在服务器返回的值


hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
<script>
function show(id)
var xmlHttp
{
window.onscroll = set_height;
byid("main").style.display = "block";
byid("main").style.height = h + "px";
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.display = "block";
byid("box").style.top = (obj.scrollTop + 50) + "px";
xmlHttp.send(id)
}
</script>




这样行吗?
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
<script>
function show(id) {
window.onscroll = set_height;
byid("main").style.display = "block";
byid("main").style.height = h + "px";
byid("main").style.top = obj.scrollTop + "px";
byid("box").style.display = "block";
byid("box").style.top = (obj.scrollTop + 50) + "px";
}
</script>


在这里我调过用alert(id)是可以得到我要的ID值的.只是ASP拿不到这个值
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
对.
<a href="javascript:show( <%=rs("id")%>);">打开 </a> 这个值是变的.我就要将这个ID的值传到服务器去,
再由asp拿到这个ID值得到库信息.
redcn2004 2008-07-11
  • 打赏
  • 举报
回复
你是要将id传过去吗?
hspcyeling 2008-07-11
  • 打赏
  • 举报
回复
<a href="javascript:show( <%=rs("id")%>);">打开 </a>
因为这个show(id)是客户端值.我要在ASP中得到这个值.可以用AJAX将show(id)的值传到服务器后,asp再调取吗?

52,802

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ajax
社区管理员
  • Ajax
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧