I am working on a website where I need multiple input boxes. I want a new box to be formed when a button is clicked. It works fine so far, but whenever a new box is formed, the data inputted in the previous boxes are reset.
How can I add to the innerHTML without resetting the input box values?
Code:
<script type="text/javascript">
function addLink() {
x = document.getElementById("addl_links");
x.innerHTML += '<br /><input type="text" name="addl_links[]" value="http://" size="20" />';
reloadBottomBar();
return false;
}
</script>
...
<tr>
<td class="row2 tableLabel">Additional Links</td>
<td class="row2">
<input type="text" name="addl_links[]" value="http://" size="20" />
<span id="addl_links"></span>
<br />
<input class="button" type="button" value="Add Another Link" onclick="addLink();" style="width: 100%;" />
</td>
</tr>