能过下以方式
<script language="JavaScript"> 
    function addFile() 
    { 
    var str = ' <select size="1" name="D1"><option value="228">绷皮主管</option><option value="229">裁剪主管</option><option value="230">车缝主管</option></select>' 
    document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str) 
    } 
</script> 
<input type="button" value="增加(Add)" onclick="addFile()"> 
在页面中生成了多个NAME为D1的下拉框,如何在ASP.NET下用程序遍历都到D1的个数,并且取得所选择的值???

解决方案 »

  1.   

    你每次调用addFile()都将生成<select>,所以会有多个同名的下拉框.你可以这样写:
    function string addFile(string s,int i)
    {
        //s是内容,i是值
        string temp;
        temp="<option value='"+i+"'>"+s+"</option>";
        return temp;
    }
    add_onclick()
    {
        bAdd=true;
    }
    在<select>中加入
    if (bAdd)
    {
        response.write(addFile(内容,值));
        bAdd=false;
    }