喜悦国际村 
» 游客:  注册 | 登录 | 搜索 | 统计 | 帮助

RSS 订阅当前论坛  

喜悦证交所已经关闭

上一主题 下一主题
     
标题: 复选框全选  
 
星之海洋2 (星之海洋2)
高级会员
Rank: 4
版主



UID 17773
精华 0
积分 904
帖子 902
金钱 904 喜悦币
威望 0
人脉 0
阅读权限 50
注册 2002-11-16
来自 hy.zj.China
状态 离线
复选框全选



<?php
<style>
BODY {FONT-SIZE9pt;}
table {FONT-SIZE9pt;}
</
style>

<
input type=checkbox id=checkall onclick=check_all()><label for=checkall>全部选择</label>    
线程数:
<input type=text id=the_thread value=10 size=2 maxlength=2 style="height:15px; font-size:12px;padding:0px">
<
br>
<
table border=0>
<
tr><td style="width:100px;over-flow:hidden"><span id=show></span></td>
<
td style="width:400px;">
<
table id=bar style="width:90%;height:10px;border:1px black solid;display:none"><tr>
<
td id=bar1 bgcolor=skyblue style="width:0%"></td>
<
td id=bar2 style="width:100%"></td>
</
tr></table>
</
td></tr>
<
tr><td colspan=2><span id=result></span></td></tr>
</
table>
<
script language="JavaScript">
/*
 This following code are designed and writen by Windy_sk <seasonx@163.net>
 You can use it freely, but u must held all the copyright items!
*/
var total 505;
var 
thread_num;
var 
pre_thread;
var 
thread = new Array();
var 
completed 0;
var 
start_time null;

for(
i=0;i<total;i++)document.write("<input type=checkbox id=cbox>");

function 
init_para(){
    
thread_num parseInt(the_thread.value);
    if(
isNaN(thread_num)) thread_num 10;
    
pre_thread Math.floor(total/thread_num);
    
result.innerText "";
    
bar1.style.width "0%";
    
bar2.style.width "100%";
    
bar.style.display "";
}

function 
check_all(){
    
checkall.disabled true;
    
init_para();
    for(var 
i=0;i<thread_num;i++){
        
thread[i]=[setInterval("thread["+i+"][1]<pre_thread?check_unit("+i+"*pre_thread + thread["+i+"][1]++):clearInterval(thread["+i+"][0])",1),0];
    }
    
thread[i]=[setInterval("thread["+i+"][1]<total%thread_num?check_unit("+i+"*pre_thread + thread["+i+"][1]++):clearInterval(thread["+i+"][0])",1),0];
}

function 
check_unit(num){
    if(
completed==0)start_time=new Date;
    
cbox[num].checked=checkall.checked;
    
completed++;
    var 
cur_rate Math.round(completed*100/total);
    
show.innerText completed "/" total " : " cur_rate "%";
    
bar1.style.width cur_rate "%";
    
bar2.style.width = (100-cur_rate) + "%";
    if(
completed == total){
        
completed 0
        checkall
.disabled false;
        
result.innerText "("+total+"单元/"+thread_num+"线程,总共耗时:"+((new Date)-start_time)+" ms)";
    }
}
</script>
?>
2003-8-10 11:44 PM#1
查看资料  访问主页  发短消息  QQ . .   顶部
     


  可打印版本 | 推荐给朋友 | 订阅主题 | 收藏主题 | 开通个人空间  


 




Powered by Discuz! 6.1.0  © 2001-2010 Comsenz Inc.
Processed in 0.026048 second(s), 6 queries

(冀ICP备05009913号) 管理员:sadly 邮箱/MSN: sadly@phpx.com QQ:824008(长隐) 清除 Cookies - - Archiver - WAP