createElement
或者隐藏几个input

解决方案 »

  1.   

    <div id="div1"></div>
    var num=document.getElementById("select1").value;//给那个select设id=select1
    document.getElementById("div1").innerHTML="";
    for(var i=0;i<num;i++)
    {
    var ifile=document.createElement("input");
    ifile.setAttribute("type","file");
    ifile.setAttribute("value","");
    ifile.setAttribute("id","FileUp"+num);
    ifile.setAttribute("class","xgsr1");
    document.getElementById("div1").appendChild(ifile);
    document.getElementById("div1").appendChild(document.createElement("br"));
    }
      

  2.   

    对了,给那个select加个事件onchange
    然后调用那段js
      

  3.   

    <script>
    function a(a){
    if(a=='1')
    {
    document.getElementById('a1').style.display = "";
    document.getElementById('a2').style.display = "none";
    document.getElementById('a3').style.display = "none";
    document.getElementById('a4').style.display = "none";
    }
    else if(a =='2')
    {
    document.getElementById('a1').style.display = "";
    document.getElementById('a2').style.display = "";
    document.getElementById('a3').style.display = "none";
    document.getElementById('a4').style.display = "none";
    }
    else if(a=='3')
    {
    document.getElementById('a1').style.display = "";
    document.getElementById('a2').style.display = "";
    document.getElementById('a3').style.display = "";
    document.getElementById('a4').style.display = "none";
    }else if(a=='4')
    {
    document.getElementById('a1').style.display = "";
    document.getElementById('a2').style.display = "";
    document.getElementById('a3').style.display = "";
    document.getElementById('a4').style.display = "";
    }
    }
    </script>
    <select name="select" id="a" onchange="a(this.value)">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
    </select>
    <div id="a1">上传图片: <input type="file" /> </div>
    <div id="a2" style="display:none;">上传图片: <input type="file" /> </div>
    <div id="a3" style="display:none;">上传图片: <input type="file" /> </div>
    <div id="a4" style="display:none;">上传图片: <input type="file" /> </div>
    隐藏的
      

  4.   

    <script>
    function a()
    {
    var num=document.getElementById("select1").value;//给那个select设id=select1
    document.getElementById("div1").innerHTML="";
    for(var i=0;i<num;i++)
    {
    var ifile=document.createElement("input");
    ifile.setAttribute("type","file");
    ifile.setAttribute("value","");
    ifile.setAttribute("id","FileUp"+num);
    ifile.setAttribute("class","xgsr1");
    document.getElementById("div1").appendChild(ifile);
    document.getElementById("div1").appendChild(document.createElement("br"));
    }
    }
    </script>
    <select id="select1"  onchange="a()">
      <option value="1">1</option>
      <option value="2">2</option>
      <option value="3">3</option>
      <option value="4">4</option>
    </select><div id="div1"> </div> 
    3楼兄弟的
      

  5.   


    <script>
    var i =1
    function a()
    {
     i++
     var row = tab.insertRow(tab.rows.length); 
     var col = row.insertCell(0);
     col.innerHTML = "<input type='text' name='a"+i+"' value='' size='40'>"; 
    }
    </script>
    <script>
    function b()
    {
     rtab.deleteRow(tab.rows.length-1); 
     }
    </script>  <input  type="button"  value="增加" onClick="a()">
      <input  type="button" value="删除" onClick="b()">
      <br>
      <table id="tab" >
        <tr>
         <td>上传图片: <td>
        </tr>
      </table>
    添加表行的
    纯粹上班无聊 练练手!!