问题是我已经做过判断,可一刷新就恢复原样,而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 {
刷新的时候要 记录原来的值
用request取值然后判断
<%
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=beginrefreshfunction 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>