[JavaScript] 动态生成下拉列表select的选项

想要动态的生成下拉列表select的选项

< html  xmlns ="http://www.w3.org/1999/xhtml"   >
< head  runat ="server" >
    
< title > 无标题页 title >
    
< script  type ="text/javascript" >
     
function PageLoad()
     
{
        
var objectSelect=document.getElementById("sltFont");
        
var Font=new Array();
        Font
=AjaxMethod.GetSystemFont().value;  //获取数据信息源
        for(var i=0;i<Font.length;i++)
        
{
            
if(Font[i]!="")
            
{
                
var objectOption=document.createElement("option");
                objectSelect.options.add(objectOption);
                objectOption.innerText
=Font[i];
                objectOption.value
=Font[i];
            }

        }

     }

    
script >
head >
< body  onload ="PageLoad();" >
    
< form  id ="form1"  runat ="server" >
    
< div >
        
< uc1:BBS_Reply  ID ="BBS_Reply1"  runat ="server"   />
    
div >
    
    
< div  id ="BBS_Reply" >
     
< table >
      
< tr >
       
< td >
           
< select  id ="sltFont" >
           
select >
       
td >
      
tr >
     
table >
    
div >
    
form >
body >
html >

 

你可能感兴趣的:([JavaScript] 动态生成下拉列表select的选项)