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
https://forums.phpfreaks.com/topic/156788-removechild-problem-in-firefox/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.