merck_delmoro Posted May 28, 2009 Share Posted May 28, 2009 how to erase the value of <input type="file">???? Quote Link to comment https://forums.phpfreaks.com/topic/160084-question-on-html-form-on-javascript/ Share on other sites More sharing options...
Alt_F4 Posted May 28, 2009 Share Posted May 28, 2009 in what context? Quote Link to comment https://forums.phpfreaks.com/topic/160084-question-on-html-form-on-javascript/#findComment-844587 Share on other sites More sharing options...
Ken2k7 Posted May 28, 2009 Share Posted May 28, 2009 Not possible. Quote Link to comment https://forums.phpfreaks.com/topic/160084-question-on-html-form-on-javascript/#findComment-844590 Share on other sites More sharing options...
merck_delmoro Posted May 28, 2009 Author Share Posted May 28, 2009 this is my code: <script type="text/javascript"> function addRow(table_id){ var clone; var rows=document.getElementById(table_id).getElementsByTagName('tr'); var index=rows.length; var newcopy = document.getElementById(table_id); var tbo=newcopy.getElementsByTagName('tbody')[0]; clone=rows[index-1].cloneNode(true); tbo.appendChild(clone); } function delRow(table_id,button){ var row = button.parentNode.parentNode; var tbo = document.getElementById(table_id).getElementsByTagName('tbody')[0]; tbo.removeChild(row); } </script> <form method="post" action="upload_file.php" enctype="multipart/form-data"> <table id="mytab"> <tr> <td>Upload File <input type="file" name="file[]" onchange="addRow('mytab')" /> <input name="del_row" type="button" value="Remove Row" onclick="delRow('mytab',this)"/></td> </tr> </table> <input type="submit" value="UPLOAD"> </form> this code will duplicate the <input type="file"> but it copies its content on it what should I change? Quote Link to comment https://forums.phpfreaks.com/topic/160084-question-on-html-form-on-javascript/#findComment-844595 Share on other sites More sharing options...
Alt_F4 Posted May 29, 2009 Share Posted May 29, 2009 try this: <script type="text/javascript"> function addRow(table_id){ var tbo=document.getElementById(table_id).getElementsByTagName('tbody')[0]; var row = document.createElement('tr'); var cell = document.createElement('td'); var clone = document.createElement('input'); clone.type='file'; clone.name='file[]'; clone.onchange=function(){addRow('mytab');}; var del = document.createElement('input'); del.type='button'; del.name='del_row'; del.onclick=function(){delRow('mytab',this);}; del.value="Remove Row" var text = document.createTextNode('Upload File '); var space = document.createTextNode(' '); cell.appendChild(text) cell.appendChild(clone); cell.appendChild(space); cell.appendChild(del); row.appendChild(cell); tbo.appendChild(row); } function delRow(table_id,button){ var row = button.parentNode.parentNode; var tbo = document.getElementById(table_id).getElementsByTagName('tbody')[0]; tbo.removeChild(row); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/160084-question-on-html-form-on-javascript/#findComment-844742 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.