[셀렉트박스,SELECT] 추가 삭제

//삭제메소드

    function CleanSelect(obj){
           var obj = eval( document.getElementById(obj) ); //select name
            //기존의 목록 clear
             for (i=0; i<obj.options.length; i++ ) {
                                             obj.options[i] = null; 
             }   
             obj.options.length = 0 ;     
    }

    //추가메소드
    function AddFileList(obj , filename){    
                var obj = eval( document.getElementById(obj) );
                 obj.options[obj.options.length] = new Option(filename , filename);       
   }

선택방법

var list = document.forms[0].selectList;
var listText = list.options[list.selectedIndex].text;

+ Recent posts