areas, controlRange ȤÀº options Ä÷º¼Ç¿¡ »õ·Î¿î ¿¤·¹¸àÆ®¸¦ Ãß°¡ÇÑ´Ù.
¹Ýȯ°ªÀº ¾ø´Ù.
¿¤·¹¸àÆ®¸¦ Ä÷º¼Ç¿¡ Ãß°¡Çϱâ À§Çؼ´Â ¸ÕÀú createElement ¸Þ¼µå·Î °³Ã¼¸¦ »ý¼ºÇÏ¿©¾ß ÇÑ´Ù.
ÀÌ ¸Þ¼µå¿¡ ÀÇÇÑ ¿¤·¹¸àÆ®ÀÇ Ãß°¡´Â ¹®¼ÀÇ ·ÎµùÀÌ ¿Ï·áµÇ¾úÀ» ¶§¸¸ °¡´ÉÇÏ´Ù.
ÀÌ ¸Þ¼µå°¡ ÀζóÀο¡ Àû¿ëµÇ¸é ·±Å¸ÀÓ ¿À·ù°¡ ¹ß»ýµÈ´Ù.
°³Ã¼ | script | IE |
---|
ÀÌ ¸Þ¼µå´Â (¿µ¾î)DOM Level 1(Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
select °³Ã¼¿¡ »õ·Î¿î Option ¼±ÅûçÇ×À» Ãß°¡ÇÑ´Ù.
<SCRIPT> function addit(){ var obj=document.myForm.selObj; var addedOpt=document.createElement('OPTION'); obj.add(addedOpt); addedOpt.innerText='Ãß°¡µÈ Ç׸ñ'+obj.length; addedOpt.value='Ãß°¡µÈ Ç׸ñ'+obj.length; addedOpt.selected=true; obj.focus(); alert('['+obj[(obj.length-1)].text+'] Ãß°¡ ¿Ï·á'); } </SCRIPT> <FORM name="myForm" action="http://koxo.com/lang/js/object/exp/xsubmit.cgi"> <SELECT name="selObj"> <OPTION value="¼±Åà Ç׸ñ 1">´çÃÊ ¼±Åà Ç׸ñ</OPTION> </SELECT> <BUTTON onClick="addit()">¼±Åà Ç׸ñ Ãß°¡</BUTTON> <INPUT type=submit value="¼Û½Å"> </FORM> <SCRIPT> var newOption=document.createElement('OPTION'); myForm.selObj.options.add(newOption); newOption.innerText='ÀÚµ¿ Ãß°¡ ¼±Åà Ç׸ñ'; newOption.value='¼±Åà Ç׸ñ 2'; </SCRIPT>