js select 다 중 선택 목록 전송 코드

6636 단어 jsselect 전송 값
js select/*왼쪽 에서 선택 한 목록 항목 을 오른쪽으로 제거 합 니 다*/function fMoveSelected Options Left ToRight(oLeft,oRight){if(!(oLeft&&oRight)) { return; } if(!hasOptions(oLeft)) { return; } if(oLeft.selectedIndex==-1) { oLeft.selectedIndex=0; } for(var i=0;i0) { oSelect.remove(ops.length-1); } } } /*select 선택 한 모든 options*/function clearSelectOptions(oSelect){if(oSelect){for(var i=0;i0 이 있 는 지 판단 합 니 다.}return false; } function checkForm(){ var onRight=document.forms[0].rightItem; alert(onRight.options.length); for(var i=0;i
[Ctrl+A 전체 선택:]js 핵심 코드

/* */
function fMoveSelectedOptionsLeftToRight(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oLeft))
{
return;
}
if(oLeft.selectedIndex==-1)
{
oLeft.selectedIndex=0;
}
for(var i=0;i<oLeft.options.length;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);
}
/* */
function fMoveAllOptionsLeftToRight(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oLeft))
{
return;
}
for(var i=0;i<oLeft.options.length;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);
}
/* */
function fMoveSelectedOptionsRightToLeft(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oRight))
{
return;
}
if(oRight.selectedIndex==-1)
{
oRight.selectedIndex=0;
}
for(var i=0;i<oRight.options.length;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);
}
/* */
function fMoveAllOptionsRightToLeft(oLeft,oRight)
{
if(!(oLeft&&oRight))
{
return;
}
if(!hasOptions(oRight))
{
return;
}
for(var i=0;i<oRight.options.length;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);
}
/* select options*/
function clearAllOptions(oSelect)
{
if(oSelect)
{
var ops=oSelect.options;
while(ops.length>0)
{
oSelect.remove(ops.length-1);
}
}
}
/* select options*/
function clearSelectedOptions(oSelect)
{
if(oSelect)
{
for(var i=0;i<oSelect.options.length;i++)
{
if(oSelect.options[i].selected)
{
oSelect.remove(i--);
}
}
}
}
/* select options*/
function hasOptions(oSelect)
{
if(oSelect)
{
return oSelect.options.length>0;
}
return false;
}

좋은 웹페이지 즐겨찾기