以下是<body>部分:
<p id="tbr"></p>
<table>
<tr><td colspan="3">用户组:<select id="gp" name="gp" onchange="checkFill(this)">
<option name="gl" value="" selected="selected"></option>
<%
sqlstr="select * from gp_list order by gl_id"
rs.open sqlstr,conn,1,1
if not(rs.bof and rs.eof) then
rs.movefirst
do while not rs.eof
response.write "<option name=""gl"" value=""" & rs("gl_id") & """ >" & rs("gl_name") & "</option>"
rs.movenext
loop
end if
rs.close
%>
</select></td></tr><tr><td> </td></tr>
<%<input name="wl" id="wl<%=rs("wl_id")%>" type="checkbox" value="<%=rs("wl_id")%>" onclick="checkAction(this)"></
sqlstr="select * from web_list order by wl_id"
rs.open sqlstr,conn,1,1
if not(rs.bof and rs.eof) then
rs.movefirst
do while not rs.eof
%>
<tr><td>td><td><%=rs("wl_name")%></td><td><%=rs("wl_dn")%></td></tr>
<%
rs.movenext
loop
end if
call connclose
%>
</table>
<input id="nil" type="hidden" value="">
</body>
checkAction函数部分:
function checkAction(checkBox)
{
var groupId;
var webId;
var transStr;
var now=new Date();
var gpl=document.getElementById("gp");
groupId=gpl.options[gpl.selectedIndex].value
webId=checkBox.value;
if(checkBox.checked==true){
transStr="action=1&gid="+groupId+"&wid="+webId+"&t="+now.getTime();
}
else{
transStr="action=2&gid="+groupId+"&wid="+webId+"&t="+now.getTime();
}
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
else{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open("Get","rightc.asp?"+transStr,true);
xmlHttp.setRequestHeader("Content-type","text/html");
xmlHttp.send();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4 && xmlHttp.status==200){
document.getElementById("tbr").innerHTML=xmlHttp.responseText;
}
}
return 0;
}
checkFill 函数部分:
function checkFill(checkBox)
{
var groupId;
var transStr;
var xmlElm;
var now=new Date();
xmlElm=0;
groupId=checkBox.options[checkBox.selectedIndex].value
transStr="action=3&gid="+groupId+"&t="+now.getTime();
if(window.XMLHttpRequest){
xmlHttp=new XMLHttpRequest();
}
else{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlHttp.open("Get","rightf.asp?"+transStr,true);
xmlHttp.setRequestHeader("Content-type","text/html");
xmlHttp.send();
xmlHttp.onreadystatechange=function(){
if(xmlHttp.readyState==4 && xmlHttp.status==200){
//返回值
if(xmlHttp.responseText!=""){
checkEmpty();
var xmlStr=xmlHttp.responseText.split("-");
for(xmlElm in xmlStr){
document.getElementById("wl"+xmlStr[xmlElm]).checked=true;
}
}
else{
checkEmpty();
}
}
}
return 0;
}
function checkEmpty() //checkFill调用
{
var chkl=document.getElementsByName("wl")
for(var x=0;x<chkl.length;x++){
chkl[x].checked=false
}
return 0;
}