<div class="codetitle"> <span><a style="CURSOR: pointer" data="49815" class="copybut" id="copybut49815" onclick="doCopy('code49815')"><u>复制代码</u></a></span> 代码如下:</div> <div class="codebody" id="code49815"> <br> <br> <br> <br><title>add_line</title> <br><script language="javascript" type="text/jscript"><!-- <br><br>function add_input_file(tbfile, index) <BR>{ <BR>file_name = "file" + index; <BR>var tr_file = document.createElement("tr"); <BR>var td_file = document.createElement("td"); <BR>var input_file = document.createElement("input") <BR>input_file.setAttribute("type","file") <BR>input_file.setAttribute("size","50") <BR>input_file.setAttribute("name",file_name) <br><br>td_file.appendChild(input_file) <BR>tr_file.appendChild(td_file) <BR>tbfile.appendChild(tr_file) <BR>} <BR>function add_one_file() <BR>{ <BR>var tb_file = document.getElementById("upload_file"); <BR>var count_file = document.getElementById("upload_file").childNodes.length; <BR>//window.alert(steps_nums); <BR>add_input_file(tb_file, count_file); <BR>} <br><br>// --></script> <br> <br> <br><div style="text-align: center"> <br><form> <br><table width="90%"> <br><tr> <br><td> <br><br> <br><br> <br><h5>配置文件上传</h5> <br> </td> <br> </tr> <br><tr> <br><td> <br><table id="upload_file"> <br><tr class="tabletext"> <br><td><input type="file" name="job" size="50"></td> <br> </tr> <br><tr class="tabletext"> <br><td><input type="file" name="file2" size="50"></td> <br> </tr> <br><tr class="tabletext"> <br><td><input type="file" name="file3" size="50"></td> <br> </tr> <br> </table> <br> </td> <br> </tr> <br><br><tr> <br><td align="left"> <br><input type="button" value="新增一行" onclick="add_one_file()"> <br><input type="submit" value="保 存"> <br><input name="ciname" value="{{ciname}}"> <br><input name="type" value="default"> <br> </td> <br> </tr> <br> </table> <br> </form> <br> </div> <br> <br> <br> </div> <br>把所有代码拷下另存为一个html文件,在浏览器中打开,点击“新增一行”按钮就可以,以下是对js函数的解释 <br><br>document.createElement 创建一种页面标签 <br>setAttribute:为某一标签设置属性 <br>appendChild:在另一标签中添加一子标签