new Option()
¢Ñ »ç¿ë¿¹) form1.sel1.options[i]=new Option("·¹À̺í","°ª",true,true)
Option() ÇÔ¼ö¿¡¼ Àμö´Â °¢°¢ text¼Ó¼º°ª,value¼Ó¼º°ª,??(¸ð¸§),±âº»¼±Åÿ©ºÎ
<script language="javascript"> function fillSel1(){ // ·ÎµùÀÌ µÇ¸é Ç׸ñA¿¡ Ç׸ñÀ» Ãß°¡ÇÏ´Â ÇÔ¼ö for(i=0;i<11;i++){ form1.sel1.options[i]=new Option(2,1,true,true) // 1ºÎÅÍ 10±îÁöÀÇ ¼ýÀÚ¸¦ °¢°¢ Ãß°¡ÇÔ } // Option() ÇÔ¼ö¿¡¼ Àμö´Â °¢°¢ text¼Ó¼º°ª,value¼Ó¼º°ª,??(¸ð¸§),±âº»¼±Åÿ©ºÎ } function add(){ // Ç׸ñA¿¡¼ Ç׸ñB·Î À̵¿½ÃÅ°´Â ÇÔ¼ö num = form1.sel2.length // Ç׸ñAÀÇ Àüü °¹¼ö¸¦ ±¸ÇÔ if(form1.sel1.selectedIndex >= 0){ v = form1.sel1.options[form1.sel1.selectedIndex].value; // ¼±ÅÃµÈ Ç׸ñÀÇ value ¼Ó¼º°ª t = form1.sel1.options[form1.sel1.selectedIndex].text; // ¼±ÅÃµÈ Ç׸ñÀÇ text ¼Ó¼º°ª form1.sel2.options[num]=new Option(t,v,true,true); // Ç׸ñB¿¡ Ãß°¡ form1.sel1.options[form1.sel1.selectedIndex]=null; // Ç׸ñA¿¡¼ »èÁ¦ } } function del(){ // Ç׸ñB¿¡¼ Ç׸ñA·Î À̵¿½ÃÅ°´Â ÇÔ¼ö num = form1.sel1.length if(form1.sel2.selectedIndex >= 0){ v = form1.sel2.options[form1.sel2.selectedIndex].value; t = form1.sel2.options[form1.sel2.selectedIndex].text; form1.sel1.options[num]=new Option(t,v,true,true); form1.sel2.options[form1.sel2.selectedIndex]=null; } } function move(sendSel,getSel){ // ¸ðµç Ç׸ñÀ» À̵¿½ÃÅ°´Â ÇÔ¼ö num = sendSel.length for(i=0;i<num;i++){ v = sendSel.options[0].value; t = sendSel.options[0].text; getSel.options[getSel.length] = new Option(t,v,true,true); sendSel.options[0] = null; } } </script> <body onLoad=fillSel1()> <form name=form1> <table> <tr> <td width="70" align="center"> <select name=sel1 size=11> </select><br> <br> Ç׸ñA </td> <td valign="middle"> <input type=button value=">" onclick="add()"><br> <input type=button value=">>" onclick="move(form1.sel1,form1.sel2)"> <br> <input type=button value="<" onclick="del()"><br> <input type=button value="<<" onclick="move(form1.sel2,form1.sel1)"> </td> <td width="70" align="center"> <select name=sel2 size=11> </select><br> <br> Ç׸ñB </td> </tr> </table> </form>