Reputation: 181
I use appends add inputs , but post form is not add inputs data.
where wrong with my code?
HTML code
<form class="form_a" action="test_a.php" method="POST" >
<div class="language">
<div class="append">
</div>
<button type="button" class="add">add Button</button>
<input type="submit" value="submit">
</div>
</form>
Javascript code
$('.language .add').click(function(){
$('.language .append').append(
'<input name="language[]" class="form-control" value="test">'
);
});
PHP code
<?php
print_r($_POST['language']);
?>
Upvotes: 0
Views: 231
Reputation: 836
If you change
</buttond>
for
</button>
, the form works just fine. Wrapping your javascript in a jQuery call helps:
$(document).ready(function(e) {
$('.language .add').click(function(){
$('.language .append').append($('<input name="language[]" class="form-control" value="test">'));
});
});
Upvotes: 1