1,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
2,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
3,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
<input type=button value=delete onclick="d()" UNSELECTABLE=true>
<script>
var n = 0
function f(u)
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file") o[i].setAttribute("ok","")
u.setAttribute("ok","ok")
}
function d()
{
o=document.getElementsByTagName("INPUT")
for(i=0;i<o.length;i++)
if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.removeChild(o[i])
}
</script>

解决方案 »

  1.   

    1,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
    2,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
    3,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"><br>
    <input type=button value=delete onclick="d()" UNSELECTABLE=true>
    <script>
    var n = 0
    function f(u)
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file") o[i].setAttribute("ok","")
    u.setAttribute("ok","ok")
    }
    function d()
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.removeChild(o[i])
    }
    </script>
      

  2.   

    TO:net_lover(孟子E章)果然厉害,
    但是如何清除删除控件留下的空白呢?
    我想把控件间排紧凑点。
      

  3.   

    去掉空白:
    <div>1,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div>
    <div>2,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div>
    <div>3,<INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div>
    <input type=button value=delete onclick="d()" >
    <script>
    var n = 0
    function f(u)
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file") o[i].setAttribute("ok","")
    u.setAttribute("ok","ok")
    }
    function d()
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.parentNode.removeChild(o[i].parentNode)
    }
    </script>
      

  4.   

    把file控件放到table里会更好控制一些,
    而且格式也比较好掌握
      

  5.   

    TO: lfecnu() 
    我用以下函数增加fiel控件,按你的方法加了<div>就有错误了。function addFile()
    {
    var str = '<div> 
    <INPUT type="file" size="50" NAME="File" onfocus="f(this)" br></div>'
    document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
    }
      

  6.   

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <TITLE> New Document </TITLE>
    <META NAME="Generator" CONTENT="EditPlus">
    <META NAME="Author" CONTENT="">
    <META NAME="Keywords" CONTENT="">
    <META NAME="Description" CONTENT="">
    </HEAD><BODY>
    <TABLE>
    <TR>
    <TD id="MyFile"><div><INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div>
    <div><INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div>
    <div><INPUT  type="file"  size="50"  NAME="File" onfocus="f(this)"></div></TD>
    </TR>
    </TABLE><input type=button value=delete onclick="d()" >
    <script>
    var n = 0
    function f(u)
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file") o[i].setAttribute("ok","")
    u.setAttribute("ok","ok")
    }
    function d()
    {
    o=document.getElementsByTagName("INPUT")
    for(i=0;i<o.length;i++)
    if(o[i].type=="file" && o[i].getAttribute("ok")=="ok") o[i].parentNode.parentNode.removeChild(o[i].parentNode)
    }
    function addFile()
    {
    var str = '<div> <INPUT type="file" size="50" NAME="File" onfocus="f(this)" br></div>'
    document.getElementById('MyFile').insertAdjacentHTML("beforeEnd",str)
    }
    </script>
    <INPUT TYPE="button" value ="添加" onclick="addFile()">
    </BODY>
    </HTML>
    没错呀!
      

  7.   

    问题已完满解决;感谢大家支持,特别感谢 net_lover(孟子E章)