资料
表格
制度
合同
管理
职场
经营
创业
范文
总结
计划
作文
文章
美文
词句
教程
模板
图片
字体
图标
办公
人事
财务
生产
管理资源吧首页
>>>
教程
>>>
编程
>>>
JavaScript教程
>>>
项目添加
<!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>Untitled Document</title> <img src="/_New/_cj/myeditor/sysimage/space.gif" class="ewebeditor__script" _ewebeditor_fake_tag="script" _ewebeditor_fake_value="%3Cscript%20language%3D%22javascript%22%3E%20%0D%0Afunction%20addItem(objForm)%20%0D%0A%20%7B%20%0D%0A%20%20var%20valueAry%3Dnew%20Array()%3B%20%0D%0A%20%20var%20textAry%3Dnew%20Array()%3B%20%0D%0A%20%20var%20leftElement%3DobjForm.elements%5B%22left%22%5D%3B%20%0D%0A%20%20var%20rightElement%3DobjForm.elements%5B%22right%22%5D%3B%20%0D%0A%20%20var%20count%3D0%3B%20%0D%0A%20%20var%20i%2Cj%2Ck%2Cflag%3B%20%0D%0A%20%20for(i%3D0%3Bi%3CleftElement.options.length%3Bi%2B%2B)%20%0D%0A%20%20%7B%20%0D%0A%20%20%20if(leftElement.options%5Bi%5D.selected)%20%0D%0A%20%20%20%7BvalueAry%5Bcount%5D%3DleftElement.options%5Bi%5D.value%3B%20%0D%0A%20%20%20%20textAry%5Bcount%5D%3DleftElement.options%5Bi%5D.text%3B%20%0D%0A%20%20%20%20count%2B%2B%3B%20%0D%0A%20%20%20%7D%20%0D%0A%20%20%7D%20%0D%0A%20%20var%20count1%3DrightElement.options.length%3B%20%0D%0A%20%20count1%3Dcount1%3E0%3Fcount1%3A0%3B%20%0D%0A%20%20for(j%3D0%3Bj%3Ccount%3Bj%2B%2B)%20%0D%0A%20%20%7B%20%0D%0A%20%20%20flag%3Dfalse%3B%20%0D%0A%20%20%20for(k%3D0%3Bk%3Ccount1%3Bk%2B%2B)%20%0D%0A%20%20%20%7B%20%0D%0A%20%20%20%20if(rightElement.options%5Bk%5D.text%3D%3DtextAry%5Bj%5D)%20%0D%0A%20%20%20%20flag%3Dtrue%3B%20%0D%0A%20%20%20%7D%20%0D%0A%20%20%20if(!flag)%20%0D%0A%20%20%7B%20%0D%0A%20%20%20%20rightElement.options%5Bcount1%5D%3Dnew%20Option(textAry%5Bj%5D%2CvalueAry%5Bj%5D)%3B%20%0D%0A%20%20%20%20count1%2B%2B%3B%20%0D%0A%20%20%20%20%7D%20%0D%0A%20%20%7D%20%0D%0A%20%7D%20%0D%0Afunction%20subItem(objForm)%20%0D%0A%20%7B%20%0D%0A%20%20var%20i%3B%20%0D%0A%20%20var%20objElement%3DobjForm.elements%5B%22right%22%5D%3B%20%0D%0A%20%20for(i%3DobjElement.options.length-1%3Bi%3E%3D0%3Bi--)%20%0D%0A%20%20%7B%20%0D%0A%20%20%20if(objElement.options%5Bi%5D.selected)%20%0D%0A%20%20%20%20objElement.options%5Bi%5D%3Dnull%3B%20%0D%0A%20%20%7D%20%0D%0A%20%7D%20%0D%0Afunction%20addAllItem(objForm)%20%0D%0A%20%7B%20%0D%0A%20%20var%20i%3B%20%0D%0A%20%20var%20leftElement%3DobjForm.elements%5B%22left%22%5D%3B%20%0D%0A%20%20for(i%3D0%3Bi%3CleftElement.options.length%3Bi%2B%2B)%20%0D%0A%20%20%7B%20%0D%0A%20%20%20leftElement.options%5Bi%5D.selected%3Dtrue%3B%20%0D%0A%20%20%7D%20%0D%0A%20%20addItem(objForm)%3B%20%0D%0A%20%7D%20%0D%0Afunction%20subAllItem(objForm)%20%0D%0A%20%7B%20%0D%0A%20%20var%20i%3B%20%0D%0A%20%20var%20rightElement%3DobjForm.elements%5B%22right%22%5D%3B%20%0D%0A%20%20for(i%3D0%3Bi%3CrightElement.options.length%3Bi%2B%2B)%20%0D%0A%20%20rightElement.options%5Bi%5D.selected%3Dtrue%3B%20%0D%0A%20%20subItem(objForm)%3B%20%0D%0A%20%7D%20%0D%0A%3C%2Fscript%3E"> </head> <body> <table width="200" cellpadding="0" cellspacing="0" border="0"> <form> <tr> <td width="80" rowspan="4"><select name="left" style="width:80px;height:100px;" multiple> <option>ITEM1</option> <option>ITEM2</option> <option>ITEM3</option> <option>ITEM4</option> <option>ITEM5</option> <option>ITEM6</option> </select></td> <td width="40" height="20" align="center"><input type="button" value=" >> " onclick="addItem(this.form);"></td> <td width="80" rowspan="4" align="right"> <select name="right" style="width:80px;height:100px;" multiple> </select> </td> </tr> <tr> <td width="40" align="center"><input type="button" value=" << " onclick="subItem(this.form)"></td> </tr> <tr> <td width="40" align="center"><input type="button" value="ALL>>" onclick="addAllItem(this.form)"></td> </tr> <tr> <td width="40" align="center"><input type="button" value="<<ALL" onclick="subAllItem(this.form)"></td> </tr> </form> </tr> </table> </body> </html>
[Ctrl+A 全选 注:
如需引入外部Js需刷新才能执行
]
教程首页
更多教程