javascript - add tr immediately after the button
I want to let user add another input file immediately next down the button, so he can select and send "x" number of files
Ive been using these answers while searching with no luck
http://stackoverflow.com/a/19200323/5586647
http://stackoverflow.com/a/19200278/5586647
http://stackoverflow.com/a/30098596/5586647
piece of my code where I want to insert new tr is
echo '<tr align=center ><td colspan="4"><input type="file" name="oc" id="oc"/></td><td><input type="button" value="add more" id="addme"/></td></tr>';
I would aprecciate a bit of help
EDIT:
While using the answers I got an issue that adds de tr (or I guess is a tr) but to a side of the original (using append)
and what I want is:
Answer
Solution:
You can use jQuery
After();
jquery.com/after/ and a click event, and make sure the input name is an array[]http://jsfiddle.net/j0jjzm7o/16/
Answer
Solution:
jQuery can do this for you using
.append()
- jquery.com/appendAn untested example...
Here is the HTML,
and the javascript,
Answer
Solution:
You will need some JavaScript(JQuery) to accomplish your task.
Live Preview: http://codepen.io/larryjoelane/pen/Nxovdj
Place the following in a script tag before your closing body tag or load it from an external file after you load JQuery. If you are unsure how to load JavaScript through an external file you can download the example from this link and explore the index.html file.
Example Download