?? selectlist.js
字號(hào):
/*
* Control two SelectList
* @author Donny.tang
* @create on 2007-2
*/
/**
* add one option of a select to another select.
*/
function addItem(ItemList,Target)
{
for(var x = 0; x < ItemList.length; x++)
{
var opt = ItemList.options[x];
if (opt.selected)
{
flag = true;
for (var y=0;y<Target.length;y++)
{
var myopt = Target.options[y];
if (myopt.value == opt.value)
{
flag = false;
}
}
if(flag)
{
Target.options[Target.options.length] = new Option(opt.text, opt.value, 0, 0);
}
}
}
}
/**
* move one selected option from a select.
*/
function delItem(ItemList)
{
for(var x=ItemList.length-1;x>=0;x--)
{
var opt = ItemList.options[x];
if (opt.selected)
{
ItemList.options[x] = null;
}
}
}
/**
* move one selected option up from a select.
*/
function upItem(ItemList)
{
for(var x=1;x<ItemList.length;x++)
{
var opt = ItemList.options[x];
if(opt.selected)
{
tmpUpValue = ItemList.options[x-1].value;
tmpUpText = ItemList.options[x-1].text;
ItemList.options[x-1].value = opt.value;
ItemList.options[x-1].text = opt.text;
ItemList.options[x].value = tmpUpValue;
ItemList.options[x].text = tmpUpText;
ItemList.options[x-1].selected = true;
ItemList.options[x].selected = false;
break;
}
}
}
/**
* move one selected option down from a select.
*/
function downItem(ItemList)
{
for(var x=0;x<ItemList.length;x++)
{
var opt = ItemList.options[x];
if(opt.selected)
{
tmpUpValue = ItemList.options[x+1].value;
tmpUpText = ItemList.options[x+1].text;
ItemList.options[x+1].value = opt.value;
ItemList.options[x+1].text = opt.text;
ItemList.options[x].value = tmpUpValue;
ItemList.options[x].text = tmpUpText;
ItemList.options[x+1].selected = true;
ItemList.options[x].selected = false;
break;
}
}
}
/**
* select all items of a select
*/
function selectItem(ItemList)
{
for(var x=ItemList.length-1;x>=0;x--)
{
var opt = ItemList.options[x];
opt.selected = true;
}
}
/**
* select one item of a select
*/
function selectOneItem(ItemList,ItemValue)
{
for(I = 0;I < ItemList.options.length; I++)
{
if(ItemValue == ItemList.options[I].value)
{
ItemList.options[I].selected = true;
}
}
}
/**
* join items of an select with ",".
*/
function joinItem(ItemList)
{
var OptionList = new Array();
for (var x=0; x<ItemList.length;x++)
{
OptionList[x] = ItemList.options[x].value;
}
return OptionList.join(",");
}
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -