I have a javascript to add additional file fields to my form. It is set to write the word “Remove” next to the added fields. This will remove the added fields from the page and will not send the values. I need to change the text content “Remove” and display and image that uses the same link to remove the field. Any help would be greatly appricated.
My code: ( The area of the “remove” text is in read )
<input name=”attachment” type=”file” id=”attachment” onchange=”document.getElementById(‘moreUploadsLink’).style.display = ‘block’;” />
<div id=”moreUploads”></div>
<div id=”moreUploadsLink” style=”display:none;”><a href=”javascript:addFileInput();”><img src=”images/addfile.jpg” border=”0″ /></a></div>
<script type=”text/javascript”>
var upload_number = 2; function addFileInput() { if(upload_number > 3) { alert(‘Sorry you can only upload 3 files’); exit(0); }
var d = document.createElement(“div”); var l = document.createElement(“a”); var file = document.createElement(“input”); file.setAttribute(“type”, “file”); file.setAttribute(“name”, “attachment”+upload_number); l.setAttribute(“href”, “javascript:removeFileInput(‘f”+upload_number+”‘);”);[COLOR=”Red”]l.className = ‘remove-btn’; l.appendChild(document.createTextNode(“Remove”));
i.setAttribute(“src”,”pics/one.png”);c.appendChild(i);}
function removeFileInput(i) { var elm = document.getElementById(i); document.getElementById(“moreUploads”).removeChild(elm); upload_number = upload_number – 1; }// decrement the max file
</script>