请教一个与页面刷新有关的问题!

逍遥散人 2003-08-05 04:48:03
我写了一段代码,作用是定时刷新页面并且在有新数据的情况下播放一个WAV文件,并且用户可以通过一个checkbox手动选择听不听这段WAV。目前,刷新与播放的功能已经完成了,可就是没法把手动选择的功能做上去,现把代码贴上,急求各位高手帮我把选择功能不上,不胜感激!!

<!--#include file="../Inc/Conn.asp"-->
<%
getstr=""
getstrdx=""
chkwav=request("chkwav")
backsound="../music.wav"

sqldx="select * from tabname where bz=0"
set rsdx=Server.CreateObject("ADODB.recordset")
rsdx.Open sqldx,conn,1,3

if rsdx.recordcount=0 then
getstrdx ="暂时没有新信息!"
else
do until rsdx.eof
getstrdx="新信息" & rsdx.recordcount & "条"
rsdx.movenext
loop
if chkwav="wavtrue" then
response.write "<bgsound src=" & backsound & " border=0 loop=1>"
end if
end if
rsdx.close
set rsdx=nothing
%>
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<script language="javascript">
<!--
var limit="0:60"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}

function beginrefresh()
{

if (!document.images)
return
if (parselimit==1)
{
window.location.reload()
}
else
{

parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
setTimeout("beginrefresh()",100)
}
}
window.onload=beginrefresh

function chksound()
{
if (document.form1.rachksound.checked==true)
{
document.form1.chkwav.value="wavtrue";
document.form1.rachksound.checked=true;
}
else if (document.form1.rachksound.checked==false)
{
document.form1.chkwav.value="wavfalse";
document.form1.rachksound.checked=false;
}
window.form1.action="";
window.form1.submit();
}
-->
</script>
<base target="_self">
</HEAD>

<BODY topmargin="0" leftmargin="0" link="#FF0000" vlink="#FF0000" alink="#FF0000">
<div align="left">
<table width="907">
<form name="form1">
<tr>
<%
if getstr ="暂时没有新数据!" then
response.write "<td align='center' width='735'>"&getstr&"</td>"
else
%><td align="center">
<marquee scrollamount=2 border=0 scrolldelay=100 onmouseover=this.stop() onmouseout=this.start()><font size="3" color="red"><%=getstr%></font></marquee>
</td>
<%
end if

if getstr ="暂时没有新信息!"then
response.write "<td align='center'>"&getstrdx&"</td>"
else
%><td align="center" width="153">
<font size="2" color="blue"><%=getstrdx%></font>
</td>
<%
end if
%>
<td width="75" align="left">
<input type="checkbox" name="rachksound" onclick="chksound()"><label>开/关声音</label>
</td>
</tr>
<input type="hidden" name="chkwav">
</form>
</table>
</div>
</BODY>
</HTML>
...全文
45 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cwwpeace 2003-08-06
  • 打赏
  • 举报
回复
有一个临时替代的做法是把这种功能做成两个框架,然后利用session和cookies把checkbox的值传给要刷新的页面不就行了吗!
逍遥散人 2003-08-06
  • 打赏
  • 举报
回复
问题是我已经做过判断,可一刷新就恢复原样,而request的值却是选择后的值。代码如下:

<!--#include file="../Inc/Conn.asp"-->
<%
getstr=""
getstrdx=""
chkwav=request("chkwav")
backsound="../music.wav"

sqldx="select * from tabname where bz=0"
set rsdx=Server.CreateObject("ADODB.recordset")
rsdx.Open sqldx,conn,1,3

if rsdx.recordcount=0 then
getstrdx ="暂时没有新信息!"
else
do until rsdx.eof
getstrdx="新信息" & rsdx.recordcount & "条"
rsdx.movenext
loop
if chkwav="wavtrue" then
response.write "<bgsound src=" & backsound & " border=0 loop=1>"
end if
end if
rsdx.close
set rsdx=nothing
%>
<HTML>
<HEAD>
<META http-equiv=Content-Type content="text/html; charset=gb2312">
<script language="javascript">
<!--
var limit="0:60"
if (document.images){
var parselimit=limit.split(":")
parselimit=parselimit[0]*60+parselimit[1]*1
}

var chkwav="<%=chkwav%>" '注意此处,此处就是判断checkbox的checked的值
if (chkwav="wavtrue")
{
document.form1.rachksound.checked=true;
}
else
{
document.form1.rachksound.checked=false;
}

function beginrefresh()
{

if (!document.images)
return
if (parselimit==1)
{
window.location.reload()
}
else
{

parselimit-=1
curmin=Math.floor(parselimit/60)
cursec=parselimit%60
setTimeout("beginrefresh()",100)
}
}
window.onload=beginrefresh

function chksound()
{
if (document.form1.rachksound.checked==true)
{
document.form1.chkwav.value="wavtrue";
document.form1.rachksound.checked=true;
}
else if (document.form1.rachksound.checked==false)
{
document.form1.chkwav.value="wavfalse";
document.form1.rachksound.checked=false;
}
window.form1.action="";
window.form1.submit();
}
-->
</script>
<base target="_self">
</HEAD>

<BODY topmargin="0" leftmargin="0" link="#FF0000" vlink="#FF0000" alink="#FF0000">
<div align="left">
<table width="907">
<form name="form1">
<tr>
<%
if getstr ="暂时没有新信息!"then
response.write "<td align='center'>"&getstrdx&"</td>"
else
%><td align="center" width="153">
<font size="2" color="blue"><%=getstrdx%></font>
</td>
<%
end if
%>
<td width="75" align="left">
<input type="checkbox" name="rachksound" onclick="chksound()"><label>开/关声音</label>
</td>
</tr>
<input type="hidden" name="chkwav">
</form>
</table>
</div>
</BODY>
</HTML>
ysharp 2003-08-05
  • 打赏
  • 举报
回复
对啊
刷新的时候要 记录原来的值
用request取值然后判断
逍遥散人 2003-08-05
  • 打赏
  • 举报
回复
楼上说得太对了,问题就出在reload上,每次reload都会把checkbox的状态变成非选择状态,可是,asp变量"chkwav"的值却仍然是选择时的值,这个问题该怎么解决呢?另外,我用location.href("top.asp")带"chkwav"参数也是同样的问题,只要一刷新就不行!
Brookes 2003-08-05
  • 打赏
  • 举报
回复
怀疑是刷新的问题。刷新的时候,你用的reload,把表里的选择给丢失了。
建议:加一个session变量纪录选泽

87,988

社区成员

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

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