0

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']);
?>
7
  • Typo: </buttond> should be </button> Commented May 6, 2016 at 14:55
  • but post form is not append add inputs data. Commented May 6, 2016 at 14:57
  • $_POST does contain all the field values... Please post your complete PHP script. Commented May 6, 2016 at 15:02
  • sorry, edit this is ok? Commented May 6, 2016 at 15:08
  • So your php code above is your complete test_a.php file, is that it? Commented May 6, 2016 at 15:10

1 Answer 1

1

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">'));
    });
});
Sign up to request clarification or add additional context in comments.

3 Comments

Sorry, where change? How can I do?
I can append input, but I submit form , php is not append data
I have it working here just fine. Please post your complete test_a.php page.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.