实现了在两个多选框内移动数据项的功能.doc_第1页
实现了在两个多选框内移动数据项的功能.doc_第2页
实现了在两个多选框内移动数据项的功能.doc_第3页
实现了在两个多选框内移动数据项的功能.doc_第4页
实现了在两个多选框内移动数据项的功能.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

实现了在两个多选框内移动数据项的功能在网页区添加以下代码 .multipleSelectBoxControl span /* Labels above select boxes*/ font-family:arial; font-size:11px; font-weight:bold; .multipleSelectBoxControl div select /* Select box layout */ font-family:arial; height:100%; .multipleSelectBoxControl input /* Small butons */ width:25px; .multipleSelectBoxControl div float:left; .multipleSelectBoxDiv /* (C) , October 2005 Download from This is a script from . You will find this and a lot of other scripts at our website. Terms of use: You are free to use this script as long as the copyright message is kept intact. However, you may not redistribute, sell or repost it without our permission. Thank you! Alf Magne Kalleland */ var fromBoxArray = new Array(); var toBoxArray = new Array(); var selectBoxIndex = 0; var arrayOfItemsToSelect = new Array(); function moveSingleElement() var selectBoxIndex = this.parentNode.parentNode.id.replace(/d/g,); var tmpFromBox; var tmpToBox; if(this.tagName.toLowerCase()=select) tmpFromBox = this; if(tmpFromBox=fromBoxArrayselectBoxIndex)tmpToBox = toBoxArrayselectBoxIndex; else tmpToBox = fromBoxArrayselectBoxIndex; else if(this.value.indexOf()=0) tmpFromBox = fromBoxArrayselectBoxIndex; tmpToBox = toBoxArrayselectBoxIndex; else tmpFromBox = toBoxArrayselectBoxIndex; tmpToBox = fromBoxArrayselectBoxIndex; for(var no=0;notmpFromBox.options.length;no+) if(tmpFromBox.optionsno.selected) tmpFromBox.optionsno.selected = false; tmpToBox.optionstmpToBox.options.length = new Option(tmpFromBox.optionsno.text,tmpFromBox.optionsno.value); for(var no2=no;no2(tmpFromBox.options.length-1);no2+) tmpFromBox.optionsno2.value = tmpFromBox.optionsno2+1.value; tmpFromBox.optionsno2.text = tmpFromBox.optionsno2+1.text; tmpFromBox.optionsno2.selected = tmpFromBox.optionsno2+1.selected; no = no -1; tmpFromBox.options.length = tmpFromBox.options.length-1; var tmpTextArray = new Array(); for(var no=0;notmpFromBox.options.length;no+) tmpTextArray.push(tmpFromBox.optionsno.text + _ + tmpFromBox.optionsno.value); tmpTextArray.sort(); var tmpTextArray2 = new Array(); for(var no=0;notmpToBox.options.length;no+) tmpTextArray2.push(tmpToBox.optionsno.text + _ + tmpToBox.optionsno.value); tmpTextArray2.sort(); for(var no=0;notmpTextArray.length;no+) var items = tmpTextArrayno.split(_); tmpFromBox.optionsno = new Option(items0,items1); for(var no=0;notmpTextArray2.length;no+) var items = tmpTextArray2no.split(_); tmpToBox.optionsno = new Option(items0,items1); function sortAllElement(boxRef) var tmpTextArray2 = new Array(); for(var no=0;noboxRef.options.length;no+) tmpTextArray2.push(boxRef.optionsno.text + _ + boxRef.optionsno.value); tmpTextArray2.sort(); for(var no=0;no)=0) tmpFromBox = fromBoxArrayselectBoxIndex; tmpToBox = toBoxArrayselectBoxIndex; else tmpFromBox = toBoxArrayselectBoxIndex; tmpToBox = fromBoxArrayselectBoxIndex; for(var no=0;notmpFromBox.options.length;no+) tmpToBox.optionstmpToBox.options.length = new Option(tmpFromBox.optionsno.text,tmpFromBox.optionsno.value); tmpFromBox.options.length=0; sortAllElement(tmpToBox); /* This function highlights options in the to-boxes. It is needed if the values should be remembered after submit. Call this function onsubmit for your form */ function multipleSelectOnSubmit() for(var no=0;noarrayOfItemsToSelect.length;no+) var obj = arrayOfItemsToSelectno; for(var no2=0;no2; buttonDiv.appendChild(buttonRight); buttonRight.onclick = moveSingleElement; var buttonAllRight = document.createElement(INPUT); buttonAllRight.type=button; buttonAllRight.value = ; buttonAllRight.onclick = moveAllElements; buttonDiv.appendChild(buttonAllRight); var buttonLeft = document.createElement(INPUT); buttonLeft.style.marginTop=10px; buttonLeft.type=button; buttonLeft.value = ; buttonLeft.onclick = moveSingleElement; buttonDiv.appendChild(buttonLeft); var buttonAllLeft = document.createElement(INPUT); buttonAllLeft.type=button; buttonAllLeft.value = ; buttonAllLeft.onclick = moveAllElements; buttonDiv.appendChild(buttonAllLeft); var subDiv = document.createElement(DIV); subDiv.style.width = (Math.floor(totalWidth/2) - 15) + px; toObj.style.width = (Math.floor(totalWidth/2) - 15) + px; var label = document.createElement(SPAN); label.innerHTML = labelRight; subDiv.appendChild(label); subDiv.appendChild(toObj); parentDiv.appendChild(subDiv); toObj.style.height = (totalHeight - label.offsetHeight) + px; fromObj.style.height = (totalHeight - label.offsetHeight) + px; selectBoxIndex+; 在网页区添加以下代码 Finland France Mexico Norway Spain United Kingdom Canada Germany United States createMovableOptions(fromBox,toBox,500,300,Available countries,Selected countries); 程序调用说明: 首先类似下面的代码创建两个多选框 Finland France Mexico Norway Spain United Kingdom Canada Germany United States 然后调用一个Javascript函数进行初始化 createMovableOptions(fromBox,toBox,500,30

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论