This code was working originally. Then I had made some modifications and things weren't going right so I went back to how it was originally, and now it's not working!
What this does is add a file text box when you click a button & then remove it when you click on its link. I get an error though when I click the Remove link saying that its argument is invalid. I don't understand why since its the exact same line of code the Add button has except assigned to a new variable.
This is the line that's coming up with the error: var d = document.getElementById('addToDiv');
in the removeAdditionalFile function. The error message says 'Invalid Argument'.
Here's the javascript:
function addFileTextbox()
{
var a = document.getElementById('addToDiv');
var b = document.getElementById('theValue');
var c = (document.getElementById('theValue').value) + 1;
b.value = c;
var newDiv = document.createElement('div');
var divIDName = 'addToDiv' + c;
newDiv.setAttribute('id', divIDName);
newDiv.innerHTML = '<input type="file" name="' + divIDName + '" size="58"> <a href="#" onclick="removeAdditionalFile(' + divIDName + ')">Remove</a>';
a.appendChild(newDiv);
}
function removeAdditionalFile(divNum)
{
var d = document.getElementById('addToDiv');
d.removeChild(divNum);
}
And here's the html:
To upload multiple files at once, click Add.
<br />
<input type="hidden" value="0" id="theValue">
<input type="button" name="add" value="Add another file" onclick="addFileTextbox();">
<FORM METHOD="POST" ENCTYPE="multipart/form-data" ACTION="repos.exe">
<INPUT TYPE=HIDDEN NAME="proc" VALUE="fileupload">
<INPUT class="hidden" TYPE="HIDDEN" NAME="AREA" VALUE="3017">
<INPUT class="hidden" TYPE="HIDDEN" NAME="FOLDER" VALUE="125258">
Find File: <INPUT TYPE="FILE" size="58" NAME="FILE">
<div id="addToDiv"> </div> <!--additional file text boxes will be added here-->
Description: (optional)<BR>
<TEXTAREA NAME="DESC" ROWS="5" COLS="54" WRAP="PHYSICAL"></TEXTAREA>
<INPUT TYPE="submit" name="submit" value="Finish" onclick="startAnimation();">
<INPUT TYPE="BUTTON" NAME="CANCEL" VALUE="Cancel" OnClick="window.close();">
Can anyone see what's wrong?