<html>
<head></head>
<body>
<form name="form1" action="?submit=yes" method="post">
<div name="uptd" id="uptd"></div>
<input type="text" name="filenum" id="filenum">
<input type="button" onclick="addfile()" value="add">
<input type="button" name="submit" value="用JS取值" onclick="JSgetvalue()"> 
<input type="submit" name="submit2" value="Form提交取值">
</form>
<br>
<div name="show" id="show"></div><%
if request.querystring("submit")="yes" then
response.write("<div>")
dim xx,yy
xx=request.form("filenum")
if IsNumeric(xx) then
for i=1 to xx
yy=request.form("info"&i)
if yy<>"" then
response.write("info"&i&"的值是:"&yy&"<br>")
end if
next
end if
response.write("</div>")
end if
%><script language="javascript">
function JSgetvalue(){
var xx=document.getElementById('filenum').value;
var oo='';
if(xx!=''&& parseInt(xx)>0){
for(var i=1;i<=xx;i++){
var zz=document.getElementById('info'+i).value;
if(zz!=''){  //只显示值不为空的项目.
var yy='info'+i+'的值是:'
oo=oo+yy+zz+'<br>';
}
}
document.getElementById('show').innerHTML=oo;
}
}
</script><SCRIPT LANGUAGE="vbscript">
function addfile()
dim str
str="<table>"
if not IsNumeric(window.form1.filenum.value) then window.form1.filenum.value =1
for i=1 to window.form1.filenum.value
str=str&"<tr><td valign='middle'>文件"&i&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'>1<input type='text' name='info"&i&"' size='10' class='tx2'></td></tr>"
next
window.uptd.innerHTML =str&"</table>"
end function
</SCRIPT>
</body>
</html>想加一个点一下就加一行的代码
像这种的
<html><head> 
<meta http-equiv="content-type" content="text/html"> 
<title>locale photo</title> 
<script> 
function AddMoreRow() 

    var oRow=event.srcElement.parentNode.parentNode; 
    var oTable=oRow.parentNode.parentNode; 
    oNewRow=oTable.insertRow(); 
    for(i=0;i<oRow.cells.length;i++) 
    { 
        oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML; 
    } 
    oRow.all("DelBtn").disabled=false; 
    oNewRow.all("DelBtn").disabled=false; 

function DeleteMoreRow() 

    var oRow=event.srcElement.parentNode.parentNode; 
    var oTable=oRow.parentNode.parentNode; 
   if(oTable.rows.length>1) 
    { 
        oTable.deleteRow(oRow.rowIndex); 
        if(oTable.rows.length==1) 
        { 
           oTable.all("DelBtn").disabled=true; 
        } 
    } 

function DisabledKeyInput() 

    if(event.keyCode!=8&&event.keyCode!=46) 
    { 
        event.returnValue=false; 
    } 

</script> 
</head><body topmargin="10"> 
<form method="post" enctype="multipart/form-data"> 
<table><th>批量上传</th></table> 
<table><tr><td nowrap="nowrap">名称*</td> 
<td><input type="text" name="Name" size="15" maxlength="50"></td><td nowrap="nowrap">文件路径*</td> 
<td><input type="file" name="FilePath" size="15" onKeyDown="DisabledKeyInput()" /></td><td nowrap="nowrap">说明*</td> 
<td><input type="text" name="Description" size="45"><input type="button" value="增加" onClick="AddMoreRow()"></td><td nowrap="nowrap"> 
<input type="button" id="DelBtn" value="删除" disabled="disabled" onClick="DeleteMoreRow()"> 
</td></tr> 
</table> 
<table> 
<tr align="center"> 
<td align="center"> 
<input type="submit" value="保存"> <input type="reset" value="取消"></td> 
</tr> 
</table> 
</form> 
</body> 
</html>下面这个主要是不知道input 的名字是什么

解决方案 »

  1.   

    this?<SCRIPT LANGUAGE="vbscript">
    function addfile()
    dim str
    str="<table>"
    if not IsNumeric(window.form1.filenum.value) then window.form1.filenum.value =1
    for i=1 to window.form1.filenum.value
    str=str&"<tr><td valign='middle'>文件"&i&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'>1<input type='text' name='info"&i&"' size='10' class='tx2'></td></tr>"
    next
    window.uptd.innerHTML =str&"</table>" &window.uptd.innerHTML 
    end function
    </SCRIPT>
      

  2.   


    <html>
    <head> 
    <meta http-equiv="content-type" content="text/html"> 
    <title>上传文件取值</title> 
    <script> 
    function AddMoreRow() 

        var oRow=event.srcElement.parentNode.parentNode; 
        var oTable=oRow.parentNode.parentNode; 
        oNewRow=oTable.insertRow(); 
        for(i=0;i<oRow.cells.length;i++) 
        { 
            oNewRow.insertCell().innerHTML=oRow.cells[i].innerHTML; 
        } 
        oRow.all("DelBtn").disabled=false; 
        oNewRow.all("DelBtn").disabled=false; 

    function DeleteMoreRow() 

        var oRow=event.srcElement.parentNode.parentNode; 
        var oTable=oRow.parentNode.parentNode; 
       if(oTable.rows.length>1) 
        { 
            oTable.deleteRow(oRow.rowIndex); 
            if(oTable.rows.length==1) 
            { 
               oTable.all("DelBtn").disabled=true; 
            } 
        } 

    function DisabledKeyInput() 

        if(event.keyCode!=8&&event.keyCode!=46) 
        { 
            event.returnValue=false; 
        } 

    </script> <script language="javascript">
    function show(){
    var aa="";
    var bb="";
    var cc="";
    var xx=document.getElementsByName("Name").length;
    for(var i=0;i<xx;i++){
    aa=aa+document.getElementsByName("Name")[i].value+",";
    bb=bb+document.getElementsByName("FilePath")[i].value+",";
    cc=cc+document.getElementsByName("Description")[i].value+",";
    }
    document.getElementById("upName").value=aa.substr(0,aa.length-1);
    document.getElementById("upFilePath").value=bb.substr(0,bb.length-1);
    document.getElementById("upDescription").value=cc.substr(0,cc.length-1);
    }
    </script></head>
    <body topmargin="10"> 
    <form method="post" enctype="multipart/form-data" action="" name="form1" onSubmit="show();document.form2.submit();">
    <table><th>批量上传</th></table> 
    <table>
    <tr>
    <td nowrap="nowrap">名称*</td> 
    <td><input type="text" name="Name" size="15" maxlength="50"></td>
    <td nowrap="nowrap">文件路径*</td> 
    <td><input type="file" name="FilePath" size="15" onKeyDown="DisabledKeyInput()" /></td>
    <td nowrap="nowrap">说明*</td> 
    <td><input type="text" name="Description" size="45"><input type="button" value="增加" onClick="AddMoreRow()"></td>
    <td nowrap="nowrap"> 
    <input type="button" id="DelBtn" value="删除" disabled="disabled" onClick="DeleteMoreRow()"> 
    </td>
    </tr> 
    </table> 
    <table> 
    <tr align="center"> 
    <td align="center"> 
    <input type="submit" value="保存"> <input type="reset" value="取消">  <input type="button" value="JS取值测试" onClick="show()"></td> 
    </tr> 
    </table>
    </form> <form name="form2" action="?save=yes" method="post" target="_blank" style="">
    名称Name: <input type="text" name="upName" id="upName"> <br>
    文件路径FilePath: <input type="text" name="upFilePath" id="upFilePath"> <br>
    说明Description: <input type="text" name="upDescription" id="upDescription"> <br>
    </form><%if request.querystring("save")="yes" then%>
    <b>以下是你取得的值,你可以将获得的值split后分别写入数据库.</b><br>
    名称: <%=request.form("upName")%><br>
    路径: <%=request.form("upFilePath")%><br>
    说明: <%=request.form("upDescription")%><br>
    <% end if%></body> 
    </html>
      

  3.   


    <SCRIPT LANGUAGE="vbscript">
    dim str,k
    k=0
    function addfile()
    dim str
    str="<table>"
    if not IsNumeric(window.form1.filenum.value) then window.form1.filenum.value =1
    for i=1 to window.form1.filenum.value
    k=k+1
    str=str&"<tr><td valign='middle'>文件"&k&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'>1<input type='text' name='info"&i&"' size='10' class='tx2'></td></tr>"next
    window.uptd.innerHTML =str&"</table>" &window.uptd.innerHTML 
    end function
    </SCRIPT>
      

  4.   


    <html>
    <head></head>
    <body>
    <form name="form1" action="?submit=yes" method="post">
    <div name="uptd" id="uptd"></div>
    <input type="text" name="filenum" id="filenum">
    <input type="button" onclick="addfile()" value="add">
    <input type="button" name="submit" value="用JS取值" onclick="JSgetvalue()"> 
    <input type="submit" name="submit2" value="Form提交取值">
    </form>
    <br>
    <div name="show" id="show"></div><%
    if request.querystring("submit")="yes" then
    response.write("<div>")
    dim xx,yy
    xx=request.form("filenum")
    if IsNumeric(xx) then
    for i=1 to xx
    yy=request.form("info"&i)
    if yy<>"" then
    response.write("info"&i&"的值是:"&yy&"<br>")
    end if
    next
    end if
    response.write("</div>")
    end if
    %><script language="javascript">
    function JSgetvalue(){
    var xx=document.getElementById('filenum').value;
    var oo='';
    if(xx!=''&& parseInt(xx)>0){
    for(var i=1;i<=xx;i++){
    var zz=document.getElementById('info'+i).value;
    if(zz!=''){  //只显示值不为空的项目.
    var yy='info'+i+'的值是:'
    oo=oo+yy+zz+'<br>';
    }
    }
    document.getElementById('show').innerHTML=oo;
    }
    }
    </script><SCRIPT LANGUAGE="vbscript">
    dim str,k
    k=0
    function addfile()
    dim str
    str="<table>"
    if not IsNumeric(window.form1.filenum.value) then window.form1.filenum.value =1
    for i=1 to window.form1.filenum.value
    k=k+1
    str=str&"<tr><td valign='middle'>文件"&k&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'>1<input type='text' name='info"&i&"' size='10' class='tx2'><input type=button onclick='delfile(this)' value='del'></td></tr>"
    next
    window.uptd.innerHTML =str&"</table>" &window.uptd.innerHTML 
    end function
    </SCRIPT><script language="javascript">
    <!--
    function delfile(_this){
    var tr=_this.parentNode.parentNode.rowIndex 
    while(_this.tagName!="TABLE")_this=_this.parentNode
    if (_this.rows.length==1)window.uptd.removeChild(_this)
    else _this.deleteRow(tr)
    }
    //-->
    </script>
    </body>
    </html>
      

  5.   

    这里删的是当前行,这样的话又出现了一个问题,就是我在中间删一行后,然后加一行,
    就会重复出两个,像
                  第4行...
                第4行...
                第3行...
                第1行...
    有没有办法让他显示成
                  第4行...
                第3行...
                第2行...
                第1行...
    或者DEL的时候删除是是上面的一行呢?
    还请多指导一下,谢谢!        
      

  6.   

    test:
    <html>
    <head></head>
    <body>
    <form name="form1" action="?submit=yes" method="post">
    <div name="uptd" id="uptd"></div>
    <input type="text" name="filenum" id="filenum">
    <input type="button" onclick="addfile()" value="add"><input type=button onclick='delfile()' value='del'>
    <input type="button" name="submit" value="用JS取值" onclick="JSgetvalue()"> 
    <input type="submit" name="submit2" value="Form提交取值">
    </form>
    <br>
    <div name="show" id="show"></div><%
    if request.querystring("submit")="yes" then
    response.write("<div>")
    dim xx,yy
    xx=request.form("filenum")
    if IsNumeric(xx) then
    for i=1 to xx
    yy=request.form("info"&i)
    if yy<>"" then
    response.write("info"&i&"的值是:"&yy&"<br>")
    end if
    next
    end if
    response.write("</div>")
    end if
    %><script language="javascript">
    function JSgetvalue(){
    var xx=document.getElementById('filenum').value;
    var oo='';
    if(xx!=''&& parseInt(xx)>0){
    for(var i=1;i<=xx;i++){
    var zz=document.getElementById('info'+i).value;
    if(zz!=''){  //只显示值不为空的项目.
    var yy='info'+i+'的值是:'
    oo=oo+yy+zz+'<br>';
    }
    }
    document.getElementById('show').innerHTML=oo;
    }
    }
    </script><SCRIPT LANGUAGE="vbscript">
    dim str,k
    k=0
    function addfile()
    dim str
    str="<table>"
    if not IsNumeric(window.form1.filenum.value) then window.form1.filenum.value =1
    for i=1 to window.form1.filenum.value
    k=k+1
    str=str&"<tr><td valign='middle'>文件"&k&":</td><td><input type='file' name='file"&i&"' class='tx1' value size='20'>  保存为<input type='text' name='file"&i&"' size='20' class='tx2'>1<input type='text' name='info"&i&"' size='10' class='tx2'></td></tr>"
    next
    window.uptd.innerHTML =window.uptd.innerHTML & str&"</table>"  
    end function
    </SCRIPT><script language="javascript">
    <!--
    function delfile(){
    var tb=window.uptd.document.getElementsByTagName("table")
    last_tb=tb[tb.length-1]
    while (last_tb.rows.length<=0){window.uptd.removeChild(last_tb);last_tb=tb[tb.length-1]}
    last_tb.deleteRow()
    k--
    }
    //-->
    </script>
    </body>
    </html>