I have a problem. The code below is for adding and removing textbox dymically through .append() and .remove(). I want all the data inside the textboxes with a placeholder of textbox will be imploded and will be placed in the textbox I set with name of textbox. Also the ones with the placeholder of box will be placed in the allotted textbox for it. How to do that?
Here's my code:
HTML
<form class="form-horizontal" method= "Post">
<div class="control-group">
<div class="inc">
<div class="controls">
<input type="text" class="form-control" name="textbox" placeholder="textbox"/>
<input type="text" class="form-control" name="text" placeholder="text"/>
<button style="margin-left: 50px" class="btn btn-info" type="submit" id="append" name="append">
Add Textbox</button>
<br>
<br>
</div>
</div>
<input type="submit" class="btn btn-info" name="submit" value="submit"/>
<input type="text" class="form-control" name="textbox" placeholder="texbox"/>
<input type="text" class="form-control" name="text" placeholder="text"/>
</div>
</form>
JavasScript:
<script type="text/javascript">
jQuery(document).ready( function () {
$("#append").click( function() {
$(".inc").append('
<div class="controls">
<input class="form-control" type="text" name="textbox" placeholder="textbox">
<input class="form-control" type="text" name="text" placeholder="text">
<a href="#" class="remove_this btn btn-danger">remove</a>
<br>
<br>
</div>');
return false;
});
jQuery('.remove_this').live('click', function() {
jQuery(this).parent().remove();
return false;
});
});
</script>