多线程的全选复选框
多线程的全选复选框
发布时间:2016-12-30 来源:查字典编辑
摘要:复制代码代码如下:BODY{FONT-SIZE:9pt;}table{FONT-SIZE:9pt;}全部选择线程数:/*Thisfollow...

复制代码 代码如下:

<style>

BODY{FONT-SIZE:9pt;}

table{FONT-SIZE:9pt;}

</style>

<inputtype=checkboxid=checkallonclick=check_all()><labelfor=checkall>全部选择</label>

线程数:<inputtype=textid=the_threadvalue=10size=2maxlength=2style="height:15px;font-size:12px;padding:0px">

<br>

<tableborder=0>

<tr><tdstyle="width:100px;over-flow:hidden"><spanid=show></span></td>

<tdstyle="width:400px;">

<tableid=barstyle="width:90%;height:10px;border:1pxblacksolid;display:none"><tr>

<tdid=bar1bgcolor=skybluestyle="width:0%"></td>

<tdid=bar2style="width:100%"></td>

</tr></table>

</td></tr>

<tr><tdcolspan=2><spanid=result></span></td></tr>

</table>

<scriptlanguage="JavaScript">

/*

ThisfollowingcodearedesignedandwritenbyWindy_sk<seasonx@163.net>

Youcanuseitfreely,butumustheldallthecopyrightitems!

*/

vartotal=505;

varthread_num;

varpre_thread;

varthread=newArray();

varcompleted=0;

varstart_time=null;

for(i=0;i<total;i++)document.write("<inputtype=checkboxid=cbox>");

functioninit_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="";

}

functioncheck_all(){

checkall.disabled=true;

init_para();

for(vari=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];

}

functioncheck_unit(num){

if(completed==0)start_time=newDate;

cbox[num].checked=checkall.checked;

completed++;

varcur_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+"线程,总共耗时:"+((newDate)-start_time)+"ms)";

}

}

</script>

下面是运行效果

BODY {FONT-SIZE: 9pt;} table {FONT-SIZE: 9pt;} 全部选择 线程数:

/* This following code are designed and writen by Windy_sk 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

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新Javascript教程学习
热门Javascript教程学习
编程开发子分类