SelectBox Item(셀렉터박스) 아이템

<html>
<head>
 <title>http://www.blueb.co.kr</title>


<SCRIPT LANGUAGE="JavaScript">
<!--
function move(fbox,tbox) {
 var i = 0;
 if(fbox.value != "") {
 var no = new Option();
  no.value = fbox.value;
  no.text = fbox.value;
  tbox.options[tbox.options.length] = no;
  fbox.value = "";
   }
}
function remove(box) {
 for(var i=0; i<box.options.length; i++) {
 if(box.options[i].selected && box.options[i] != "") {
  box.options[i].value = "";
  box.options[i].text = "";
    }
 }
 BumpUp(box);
}
function BumpUp(abox) {
 for(var i = 0; i < abox.options.length; i++) {
 if(abox.options[i].value == "")  {
 for(var j = i; j < abox.options.length - 1; j++)  {
  abox.options[j].value = abox.options[j + 1].value;
  abox.options[j].text = abox.options[j + 1].text;
 }
 var ln = i;
 break;
   }
}
 if(ln < abox.options.length)  {
  abox.options.length -= 1;
  BumpUp(abox);
   }
}
function Moveup(dbox) {
 for(var i = 0; i < dbox.options.length; i++) {
 if (dbox.options[i].selected && dbox.options[i] != "" && dbox.options[i] != dbox.options[0]) {
 var tmpval = dbox.options[i].value;
 var tmpval2 = dbox.options[i].text;
  dbox.options[i].value = dbox.options[i - 1].value;
  dbox.options[i].text = dbox.options[i - 1].text
  dbox.options[i-1].value = tmpval;
  dbox.options[i-1].text = tmpval2;
      }
   }
}
function Movedown(ebox) {
 for(var i = 0; i < ebox.options.length; i++) {
 if (ebox.options[i].selected && ebox.options[i] != "" && ebox.options[i+1] != ebox.options[ebox.options.length]) {
 var tmpval = ebox.options[i].value;
 var tmpval2 = ebox.options[i].text;
  ebox.options[i].value = ebox.options[i+1].value;
  ebox.options[i].text = ebox.options[i+1].text
  ebox.options[i+1].value = tmpval;
  ebox.options[i+1].text = tmpval2;
      }
   }
}
//-->
</script>

</HEAD>

<BODY>

<form ACTION="" METHOD="POST">
<table>
<tr>
 <td colspan=2>
  <input type="text" name="list1" size=21 value=""> <input type="button" value="추가" onclick="move(this.form.list1,this.form.list2)" name="B1" style="width:60">

 </td>
</tr>
<tr>
 <td>
  <select multiple size=7 name="list2" style="width:160">
  <option value="one">하나</option>
  <option value="two">둘</option>
  <option value="three">셋</option>
  <option value="four">넷</option>
  <option value="five">다섯</option>
  <option value="six">여섯</option>
  </select>
 </td>
 <td>
  <input type="button" value="삭제" onclick="remove(this.form.list2)" name="B2" style="width:60">

  <input type="button" value="위로" onclick="Moveup(this.form.list2)" name="B3" style="width:60">

  <input type="button" value="아래로" onclick="Movedown(this.form.list2)" name="B4" style="width:60">
 </td>
</tr>
</table>
</form>

</BODY>
</HTML>

selectBox-ex.html

Posted by 말없제이
,