IE支持让你动态增加元素,但是不支持动态删除元素:)所以你要变通一下了……比如,隐藏起来,修改某个javascript变量做为标志,说明某个Form被隐藏了……等等。具体的操作还是你自己多想想吧,我不知道上面的思路对你有没有帮助。

解决方案 »

  1.   

    function insertAttachment()
    {
    document.all.newAttachmentAnchor.insertAdjacentHTML("AfterBegin","<input type='file' name='attachment' class='text' size='50'/><BR/>");
    }

    function resetAttachment()
    {
    //text = "<input type='file' name='attachment' class='text' size='50'/><br>";
    //text+= "<span id='newAttachmentAnchor' onclick='insertAttachment()' style='cursor:hand;'>更多附件</span>&#160;";
    //text+= "<span id='restoreAttachmentZone' onclick='resetAttachment()' style='cursor:hand;'>重置所有</span>";
    attchmentZone.innerHTML = attachmentHtml;
    }...
    <span id="attchmentZone">
    <input type="file" name="attachment" class="text" size="50"/>
    <br/>
    <span id="newAttachmentAnchor" onclick="insertAttachment()" style="cursor:hand;">
    <img src="{$host}/images/ForumBtnAddAttachment.gif" width="16" height="16" alt=""/>更多附件</span>
    &#160;
    <span id="restoreAttachmentZone" onclick="resetAttachment()" style="cursor:hand;">
    <img src="{$host}/images/ForumBtnDelAttachment.gif" width="16" height="16" alt=""/>重置所有</span>
    </span>
      

  2.   

    主要要用到DHTML的insertAdjacentHTML
      

  3.   

    抱歉,刚才没看清楚你的意图
    针对sharetop(天生不笨)兄的设想补充一点,你可以在隐藏的同时,把它的innerHTML设为空,这就间接起到了删除的作用。
      

  4.   

    原来是说innerHTML这个方法,这是可以增加或删除HTML元素,通过写HTML标签加入来实现,我想到的是那个只被IE支持的createElement方法,可以动态向select里加option的,但是不能删除:)
      

  5.   

    推荐一个好网站http://javascript.internet.com/
      

  6.   

    <script>
    function delRows(){
    var tb=document.all.tablelist;
    var iRowIndex = getRows() ;
    if(tb && tb.tagName=="TABLE")
    {
    tb.deleteRow(iRowIndex) ;
    var iRows=tb.rows.length ;
    for (var i=iRowIndex;i<iRows;i++){
    tb[i]=tb[i+1];
    tb.length=tb.length-1;
    }
    }
    }function getRows(){
    var src=event.srcElement;
    var row=src.parentElement.parentElement;
    if(row && row.tagName=="TR") 
    return row.rowIndex;
    }</script>
    <BODY BGCOLOR="#FFFFFF">
    <table border="1" id="tablelist">
    <tr><td><input type=button value=删除 onclick="delRows();"><td><input type=text value="aaaaaa"><td><input type=radio><td><input type=checkbox></tr>
    <tr><td><input type=button value=删除 onclick="delRows();"><td><input type=text value="bbbbb" ><td><input type=radio><td><input type=checkbox></tr>
    <tr><td><input type=button value=删除 onclick="delRows();"><td><input type=text value="ccccc"><td><input type=radio><td><input type=checkbox></tr>
    <tr><td><input type=button value=删除 onclick="delRows();"><td><input type=text value="dddd"><td><input type=radio><td><input type=checkbox></tr>
    <tr><td><input type=button value=删除 onclick="delRows();"><td><input type=text value="ddddd"><td><input type=radio><td><input type=checkbox></tr>
    </table>
    </BODY>try: