Problem with old Javascript function and adding Chosen
I have the following function in a .js file that has worked fine for years:
function cloneFileUploadElement(theButton) {
fileInputElementIncrement++;
var objForm = document.getElementById("uploadForm");
var theClone = elToClone.cloneNode(true);
theClone.name = uploadForm.firstChild.name + fileInputElementIncrement;
theClone.id = uploadForm.firstChild.name + fileInputElementIncrement;
objForm.insertBefore(theClone, objForm.clonebutton);
}
And the snippet in the HTML is as follows:
<input style="display:block;" type="file" id="UploadFile" name="UploadFile" onchange="testtype(this)" />
<script type="text/javascript">
<!--
/* //<![CDATA[*/
if (document.getElementById) {
document.writeln('<input id="clonebutton" type="button" value="...Add More Files" onclick="cloneFileUploadElement(this);return false;" \/>');
}
var fileInputElementIncrement = 1;
/* //]]>*/
//-->
</script>
When I added the .js files for the Chosen Plugin, it broke the above. I'm figuring it has something to do with the cloneNode, but I'm not experienced enough in javascript to know what to change. Possibly if the above could be converted to jquery version, but again I'm not too sure where to start there either. Any help would be greatly appreciated