我的问题是这样的:
一系列<input type="text" name="name[]">的input项目,我用javascript将他们都从html移除后,在firefox下,依然可以用form['name[]']取得input的一个值,在IE下,正常。请问有什么方法可以彻底移除这个input项??

解决方案 »

  1.   

    innerHTML = '';
    ??
    是可以的吧。
      

  2.   

    把节点删除吧:var body=document.lastChild.lastChild;
    var input=document.getElementsByTagName("input");//保证input为body的子标签
    for(var i=0,len=input.length;i<len;body.removeChild(input[i]),i++);//大概这样,要删除的条件自己加
      

  3.   

    不存在这样的情况,IE6和Firefox都正常。
    <html xmlns="http://www.w3.org/1999/xhtml" >
    <head>
        <title></title>
        <script type="text/javascript">        function clickHandler()
            {
                var txt = document.getElementById("txt");
                txt.parentNode.removeChild(txt);
                window.alert(document.form1.txt.value);            
            }
           
        </script>
    </head>
    <body>
    <form id="form1" name="form1">
    <input type="text" id="txt" /><input type="button" onclick="clickHandler()" value="button" />
    </form>
    </body>
    </html>
      

  4.   

    先取得所有name属性是指定名字的所有元素,然后删除。
    var input=document.getElementsByTagName("input");
    for(var i=0;i<input.length;i++)
    {
      var txt = document.getElementByName("name[" + i + "]");
      txt.parentNode.removeChild(txt);
    }