Option ű׿¡ ÀÇÇÏ¿© ÁöÁ¤µÈ ¹®ÀÚ¿À» ¹ÝȯÇϰųª ¼³Á¤ÇÑ´Ù.
ÀÌ ¼Ó¼ºÀº Àбâ/¾²±âÀÌ¸ç µðÆúÆ®°ªÀº ¾ø´Ù.
°³Ã¼ | script | HTML | ±Ô°Ý | IE |
---|
ÀÌ ¼Ó¼ºÀº (¿µ¹®)DOM1(World Wide Web Consortium Document Object Model Level 1)¿¡¼ Á¤ÀǵǾú´Ù.
OptionÀÇ °ª(value)Àº º¯°æ½ÃÅ°Áö ¾Ê°í, ¼±Åà ¹®ÀÚ¿(text)¸¸ º¯°æ½ÃŲ´Ù.
<SCRIPT> function changeText(){ for(var i=0;i<FNAME.selObj.options.length;i++){ fname.selObj.options[i].text=fname.selObj.options[i].text+i; } } function showText(){ var str=''; for(var i=0;i<FNAME.selObj.options.length;i++){ str+=i+'] value='+fname.selObj.options[i].value+', text='+fname.selObj.options[i].text+'<BR>'; } showA.innerHTML=str; } </SCRIPT> <FORM name=fname action="../object/exp/xsubmit.cgi"> <SELECT id=selObj name=selName onchange="showText()"> <OPTION value="apple">apple <OPTION value="orange">orange <OPTION value="peach">peach <OPTION value="pear">pear </SELECT> <INPUT type=button value="Ŭ¸¯ÇÏ¿© º¯°æÇØ º¸±â" onclick="changeText()"> <INPUT type=submit value="¼Û½Å"> </FORM> <DIV id=showA> </DIV>