Jump to content

removeChild problem in Firefox


warhead2020

Recommended Posts

Hi, i have this problem. This in my code.

 

function addElement() 
{ 
   var ni = document.getElementById('myDiv'); 
   var numi = document.getElementById('theValue'); 
   var num = (document.getElementById('theValue').value -1 + 2); 
   numi.value = num; 
   var newdiv = document.createElement('div'); 
   var divIdName = 'my'+num+'Div'; 
   newdiv.setAttribute('id',divIdName); 
   newdiv.innerHTML = '<input type=file id=imgfile' + num + ' name=imgfile' + num + '><a href="javascript:remove('+divIdName+')">Remove</a>'; 
   ni.appendChild(newdiv); 
} 


function remove(dId) 
{ 
   var ni = document.getElementById('myDiv'); 
   var numi = document.getElementById('theValue'); 
   var num = (document.getElementById('theValue').value -1 + 0);
   numi.value = num; 
   ni.removeChild(dId); 
} 

 

<p>
    <a href="javascript:addElement()" >Add Upload Field</a>
</p>
<p>
    <input type="hidden" value="0" id="theValue" name="theValue"/> 
</p>
<p></p>
<table width="100%" border="0">
<tr>
      <td>
            <div id="myDiv">
            </div>
      </td>
</tr>
<tr>
      <td>
      <label>
      <input type="submit" name="button" id="button" value="Submit" />
      </label>
      </td>
</tr>
</table>

 

the problem is, when i once i remove the Upload button, i cannot remove anymore. This is the sequence... Add Upload -> Remove Upload -> Add Upload -> Remove Upload (but this time,i cannot remove it.) . This problem happen in firefox, for IE, it works flawlessly. Hope anyone can help me solve this problem. Thanx in advance.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.