Home > Web Front-end > JS Tutorial > js select multi-select list value passing code_form special effects

js select multi-select list value passing code_form special effects

WBOY
Release: 2016-05-16 18:40:06
Original
1041 people have browsed it

[Ctrl A Select all Note: If you need to introduce external Js, you need to refresh to execute ]


js core code
Copy code The code is as follows:

/*Remove the selected list item on the left to the right* /
function fMoveSelectedOptionsLeftToRight(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oLeft))
{
return;
}
if(oLeft.selectedIndex==-1)
{
oLeft.selectedIndex=0;
}
for(var i= 0;i{
if(oLeft.options[i].selected)
{
var oOption = document.createElement("OPTION");
oOption.setAttribute("text",oLeft.options[i].text);
oOption.setAttribute("value",oLeft.options[i].value);
oRight.add(oOption) ;
}
}
clearSelectedOptions(oLeft);
}
/*Remove all list items on the left to the right*/
function fMoveAllOptionsLeftToRight(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oLeft))
{
return;
}
for(var i=0;i{
var oOption = document.createElement("OPTION");
oOption.setAttribute("text",oLeft. options[i].text);
oOption.setAttribute("value",oLeft.options[i].value);
oRight.add(oOption);
}
clearAllOptions(oLeft) ;
}
/*Remove the selected list item on the right to the left*/
function fMoveSelectedOptionsRightToLeft(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oRight))
{
return;
}
if(oRight.selectedIndex==-1)
{
oRight.selectedIndex=0;
}
for(var i=0;i{
if(oRight.options[i].selected)
{
var oOption = document.createElement("OPTION");
oOption.setAttribute("text",oRight.options[i].text);
oOption.setAttribute("value" ,oRight.options[i].value);
oLeft.add(oOption);
}
}
clearSelectedOptions(oRight);
}
/*Remove the right one All list items to the left*/
function fMoveAllOptionsRightToLeft(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(! hasOptions(oRight))
{
return;
}
for(var i=0;i{
var oOption = document. createElement("OPTION");
oOption.setAttribute("text",oRight.options[i].text);
oOption.setAttribute("value",oRight.options[i].value);
oLeft.add(oOption);
}
clearAllOptions(oRight);
}
/*Clear all select options*/
function clearAllOptions(oSelect)
{
if(oSelect)
{
var ops=oSelect.options;
while(ops.length>0)
{
oSelect.remove(ops.length-1);
}
}
}
/*Clear all selected options*/
function clearSelectedOptions(oSelect)
{
if(oSelect)
{
for (var i=0;i{
if(oSelect.options[i].selected)
{
oSelect.remove(i--);
}
}
}
}
/*Judge whether select has options*/
function hasOptions(oSelect)
{
if(oSelect)
{
return oSelect.options.length>0;
}
return false;
}
">
Related labels:
js
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Recommendations
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template