How Do I Appendchild A File Upload Field With I++?
Solution 1:
There's a few things wrong with that.
JSFiddle problems
First of all, you still have the framework settings set to "onLoad" and "Mootools". You'll want it to be one of the "no wrap" options and "No-Library (pure JS)". Secondly, you're putting the script in a script
tag in the HTML pane. There's a JavaScript pane specifically for JavaScript.
JavaScript problems
You have some inline HTML in your JavaScript:
newDiv.innerHTML = "<input type="file" name="file1 + i++" />";
You're using double quotes ("
) for your JavaScript string as well as inside the HTML. Try using single quotes for the JavaScript string delimiters, like this:
newDiv.innerHTML = '<input type="file" name="file1' + (i++) + ' />';
The HTML inside the string is also not valid. It will try to generate HTML like this:
<input type="file" name="file10 />
There's no closing quote. Fix that:
newDiv.innerHTML = '<input type="file" name="file1' + (i++) + '" />';
You might also want to remove the stray 1
, though it doesn't break the script.
Result
Here it is, after these changes and a few more.
Post a Comment for "How Do I Appendchild A File Upload Field With I++?"