- HTML code
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" " http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns=" http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>无标题文档</title><script type="text/javascript">var resources = [{url:" http://ftp.pconline.com.cn/pub/download/200903/setupnod32_pconline.exe"},{url:" http://down1.sec520.com/soft/094/02hsfw.jpg"}];var Thunder=null;var download,addTask,commitTasks,batchDownload=null;var Delegate={create:function(obj,func){var f=function(){var target=arguments.callee.target;var func=arguments.callee.func;return func.apply(target,arguments);};f.target=obj;f.func=func;return f;}};try{ Thunder=new ActiveXObject("ThunderServer.webThunder.1"); download=function(cid,url,refer,name,stat){ Thunder.CallAddTask(url,name,refer,1,cid,stat); } batchDownload=function(data,stat){ var batchTask=Thunder.BeginBatchTask(); if(batchTask==0){ alert("批量下载初始化失败");return; } }}catch(e){ try{ Thunder=new ActiveXObject("ThunderAgent.Agent.1"); addTask=function(cid,url,refer,name,stat){ var _addTask=[Delegate.create(this,function(){Thunder.AddTask4(url,"","",name,refer,-1,0,-1,"",cid,stat);}), Delegate.create(this,function(){Thunder.AddTask3(url,"","",name,refer,-1,0,-1,"",cid);}), Delegate.create(this,function(){Thunder.AddTask2(url,"","",name,refer,-1,0,-1,"");}), Delegate.create(this,function(){Thunder.AddTask(url,"","",name,refer,-1,0,-1);})]; for(var i=0;i<_addTask.length;i++){ try{ _addTask[i](); return; }catch(e){} } } commitTasks=function(){ var _commitTasks=[Delegate.create(this,function(){Thunder.CommitTasks2(1);}), Delegate.create(this,function(){Thunder.CommitTasks();})]; for(var i=0;i<_commitTasks.length;i++){ try{ _commitTasks[i](); return; }catch(e){} } } download=function(cid,url,refer,name,stat){ try{ this.addTask(cid,url,refer,name,stat); this.commitTasks(); }catch(e){ alert(e.message); } } batchDownload=function(data,stat){ try{ for(i=0;i<data.length;i++){ alert(data[i].url) this.addTask(data[i].cid,data[i].url,data[i].refer,data[i].name,stat); } this.commitTasks(); }catch(e){ alert(e.message); } } }catch(e){ alert("迅雷初始f化失败!"); }}</script></head><body><input type="checkbox" name="test" value="http://localhost:8080/SSE1210/1.jpg"><input type="checkbox" name="test" value="http://localhost:8080/SSE1210/1.jpg"><p> <label> <input type="button" name="Submit2" value="批量" onclick="batchDownload(resources,'')" /> </label></p></body></html>
我想讲上面代码中 checkbox中value值(url)添加到 定义好的var resources 中如何实现
效果是 当我选择了checkbox中的一个 添加一个进去 选择了2个添加两个进去
------解决方案--------------------
checkbox标签写onclick事件。
<input type="checkbox" name="test" onclick="resources[resources.length] = this.value" value="http://localhost:8080/SSE1210/1.jpg">