<html>
<head>
<script language="javascript">
<!--
function LinkedDropList(oSelA,oSelB){
var dropList1 = oSelA
var dropList2 = oSelB
var autoRemove = true
var ignoreRepeat = false
//+-------------------------------------------------
this.setAutoRemove=function(bStatus){
autoRemove = ("boolean" == typeof(bStatus) ? bStatus : false)
}
//+--------------------------------------------------
this.setIgnoreRepeat=function(bStatus){
ignoreRepeat = ("boolean" == typeof(bStatus) ? bStatus : false)
}
//+--------------------------------------------------
this.move=function(sDirection,nIndex){
if(sDirection=='forward'){
moveForward(nIndex)
}
else{
moveBack(nIndex)
}
}
this.moveAll=function(sDirection){
var oSrc,nTotal
if(sDirection=='forward'){
nTotal=dropList1.length
}
else{
nTotal=dropList2.length
}
for(var i = 0;i < nTotal;i ++){
if (!autoRemove){
this.move(sDirection,i)
}
else{
this.move(sDirection,0)
}
}
}
//+-------------------------------------------------
function moveBack(nIndex){
move(dropList2,dropList1,nIndex)
}
//+-------------------------------------------------
function moveForward(nIndex){
move(dropList1,dropList2,nIndex)
}
//+--------------------------------------------------
function move(oSrc,oTagert,nIndex){
var oCurOption
if(typeof(nIndex)=="undefined"){
if (-1 == oSrc.selectedIndex)
return
oCurOption=oSrc.options[oSrc.selectedIndex]
}
else{
oCurOption=oSrc.options[nIndex]
}
//check if it has added
if (!ignoreRepeat){
for(var i=0;i<oTagert.length;i++){
if(oCurOption.value == oTagert.options[i].value){
alert(oTagert.options[i].value)
oTagert.options[i].selected=true
return
}
}
}
//move element
oTagert.appendChild(oCurOption.cloneNode(true))
if(autoRemove){
oSrc.removeChild(oCurOption)
}
}
dropList1.ondblclick = moveForward
dropList2.ondblclick = moveBack
}var ld
function window.onload(){
ld = new LinkedDropList(selA,selB)}
//-->
</script>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<select id="selA" size="5" style ="width:150">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
<select id="selB" NAME="Select1" style ="width:150" size="5">
</select>
<br>
<input type="button" value=">" onclick="ld.move('forward')">
<input type="button" value="<" onclick="ld.move('back')">
<input type="button" value=">>" onclick="ld.moveAll('forward')">
<input type="button" value="<<" onclick="ld.moveAll('back')">
<input type="checkbox" onclick="ld.setIgnoreRepeat(this.checked)">忽略重复值
<input type="checkbox" checked onclick="ld.setAutoRemove(this.checked)">自动删除原选项
</body>
</html>
<head>
<script language="javascript">
<!--
function LinkedDropList(oSelA,oSelB){
var dropList1 = oSelA
var dropList2 = oSelB
var autoRemove = true
var ignoreRepeat = false
//+-------------------------------------------------
this.setAutoRemove=function(bStatus){
autoRemove = ("boolean" == typeof(bStatus) ? bStatus : false)
}
//+--------------------------------------------------
this.setIgnoreRepeat=function(bStatus){
ignoreRepeat = ("boolean" == typeof(bStatus) ? bStatus : false)
}
//+--------------------------------------------------
this.move=function(sDirection,nIndex){
if(sDirection=='forward'){
moveForward(nIndex)
}
else{
moveBack(nIndex)
}
}
this.moveAll=function(sDirection){
var oSrc,nTotal
if(sDirection=='forward'){
nTotal=dropList1.length
}
else{
nTotal=dropList2.length
}
for(var i = 0;i < nTotal;i ++){
if (!autoRemove){
this.move(sDirection,i)
}
else{
this.move(sDirection,0)
}
}
}
//+-------------------------------------------------
function moveBack(nIndex){
move(dropList2,dropList1,nIndex)
}
//+-------------------------------------------------
function moveForward(nIndex){
move(dropList1,dropList2,nIndex)
}
//+--------------------------------------------------
function move(oSrc,oTagert,nIndex){
var oCurOption
if(typeof(nIndex)=="undefined"){
if (-1 == oSrc.selectedIndex)
return
oCurOption=oSrc.options[oSrc.selectedIndex]
}
else{
oCurOption=oSrc.options[nIndex]
}
//check if it has added
if (!ignoreRepeat){
for(var i=0;i<oTagert.length;i++){
if(oCurOption.value == oTagert.options[i].value){
alert(oTagert.options[i].value)
oTagert.options[i].selected=true
return
}
}
}
//move element
oTagert.appendChild(oCurOption.cloneNode(true))
if(autoRemove){
oSrc.removeChild(oCurOption)
}
}
dropList1.ondblclick = moveForward
dropList2.ondblclick = moveBack
}var ld
function window.onload(){
ld = new LinkedDropList(selA,selB)}
//-->
</script>
<title></title>
<meta name="GENERATOR" content="Microsoft Visual Studio.NET 7.0">
<meta name="vs_targetSchema" content="http://schemas.microsoft.com/intellisense/ie5">
</head>
<body>
<select id="selA" size="5" style ="width:150">
<option value="a">A</option>
<option value="b">B</option>
<option value="c">C</option>
</select>
<select id="selB" NAME="Select1" style ="width:150" size="5">
</select>
<br>
<input type="button" value=">" onclick="ld.move('forward')">
<input type="button" value="<" onclick="ld.move('back')">
<input type="button" value=">>" onclick="ld.moveAll('forward')">
<input type="button" value="<<" onclick="ld.moveAll('back')">
<input type="checkbox" onclick="ld.setIgnoreRepeat(this.checked)">忽略重复值
<input type="checkbox" checked onclick="ld.setAutoRemove(this.checked)">自动删除原选项
</body>
</html>
解决方案 »
- web方面
- if(obj.filters)?这个filters是什么意思?在线求解
- 为什么这个非空验证不起作用
- 点击链接弹出指定页面指定ID内容,要怎么做?
- CSS有这个功能吗?
- 关于页面验证的问题,出不来,大家帮忙看看!
- 请教页面元素消隐的问题???
- 这是jsp里的一段,现在我想让用户点击input框后,自动清空,如何写onclick后边的代码?
- 窗口的变量的问题.........急!!!!!!!!!!!!!!!!!!!!!!11(100分,简单而又简单,但又奇怪的东东)
- 怎样动态改变iframe元素的宽高?
- 分帧的窗口如何最大化?
- 如何判断网页是被别的窗口用window.open打开的还是直接用链接打开的?
-----------------------------------------------
1.substr 方法
返回一个从指定位置开始的指定长度的子字符串。
stringvar.substr(start [, length ])2.substring 方法
返回位于 String 对象中指定位置的子字符串。 strVariable.substring(start, end)
"String Literal".substring(start, end)