日期:2014-05-17  浏览次数:20697 次

给html中的select控件自动添加数据
function AddRow()
{      
  var myTable = document.getElementByI("ctl00_ContentPlaceHolder1_zjjzzTB");        var newRowIndex = myTable.rows.length;        //添加一行       
 var newTr = myTable.insertRow();        //添加五列      
  var newTd0 = newTr.insertCell();        
var newTd1 = newTr.insertCell();       
 var newTd2 = newTr.insertCell();       
 var newTd3 = newTr.insertCell();//设置列内容和属性          newTd0.className="zztd";       
  newTd1.className="zztd";      
   newTd2.className="zztd";        
 newTd3.className="zztd";                 
  newTd0.innerHTML = newRowIndex;        
 newTd1.innerHTML = 
'<input type=text id="zjlx'+ newRowIndex+'" name="zjlx'+newRowIndex+'"/>';      
//'<input type=text id="zjbh'+ newRowIndex +'" name="zjbh'+newRowIndex+'"/>'        newTd2.innerHTML = '<select id="zjbh'+ newRowIndex +'" style="width:102px"><option>选择仓库</option></select>';      
   newTd3.innerHTML = '<input type=text  readonly="readonly" id="fzrq'+ newRowIndex +'" name="fzrq'+newRowIndex+'"/>';            
   }

这是我的自动添加记录行的代码,里面有一个select控件,现在需要从后台自动添加数据,哪里大侠帮忙看看。谢谢 
html select控件? 自动添加数据?

------解决方案--------------------
从后台得到数据拼成字符串,传递到前台,生成控件
后台:
protected string htmlstr
//(根据数据加以处理)
前台:
<%=htmlstr%>

处理这个字符串