warhead2020 Posted May 4, 2009 Share Posted May 4, 2009 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. Quote Link to comment Share on other sites More sharing options...
jackpf Posted May 4, 2009 Share Posted May 4, 2009 Just found this - http://www.webdeveloper.com/forum/showthread.php?t=148204 It looks as though you have to give removeChild() the full reference to the element (ie, document.getElement.....) rather than a variable containing it. Idk, give it a go. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.