动态从数据库中获取数据填充Select

//所有版块
	$(function(){
		getMissiveType();
	});
	function getMissiveType(){ 
    $.ajax({ 
         type:"POST", 
         dataType: "json", 
         url:"<%=basePath%>TopicSectionModeratorServlet", 
         data:"doaction=sectionList", 
         success:function(data){ 
               var len=data.length; 
               $('#sectionName-s').attr("length",'0'); 
         for(i=0;i<len;i++){ 
        	 $("#sectionName-s").append($('<option value='+data[i].key+'>'+data[i].sectionName+'</option>'));
 } 
} 
} 
); 
} 

===========
<select name="sectionName-s" id="sectionName-s" style="width:50%"> 
                 
        </select>

相关推荐