Dynamically Add / Remove input fields in PHP with Jquery Ajax

Add or Remove input fields dynamically with Ajax JQuery. Add Input Field using Jquery. How to Add / Remove textbox dynamically with Jquery. Javascript add input fields dynamically. Dynamically add input fields and submit to database with Jquery and PHP. Add Field dynamically to form in jquery and php. Dynamically Add form fields PHP.

Check our new PHP Project with Complete Source Code

PHP Mysql Chat Application with WebSocket – https://www.youtube.com/watch?v=l2P0dgjz8wQ&list=PLxl69kCRkiI0U4rM9RA1VBah5tfU26-Fp

PHP Project on Student Result Management System – https://www.youtube.com/watch?v=hTojMOVKDZ0

Restaurant Management System Created using PHP – https://www.youtube.com/watch?v=UY5pxaL0yJQ

Visitor Management System in PHP Mysql using Ajax jQuery – https://www.youtube.com/watch?v=1oY3dH8LV3w

Source Code – http://www.webslesson.info/2016/02/dynamically-add-remove-input-fields-in-php-with-jquery-ajax.html

29 thoughts on “Dynamically Add / Remove input fields in PHP with Jquery Ajax

  1. coders! if you follow this 'by the book', you will notice an error that won't allow you to add new text areas and send data. this happens because you need to import jquery first (just paste " <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script> " to the HTML head), and there's another issue with name.php; this " $sql = "INSERT INTO tbl_name(name) VALUES('".mysqli_real_escape_string($connect, $_POST["name"][$i]."')"; " thing doesn't work. still trying to figure out what's happening.

  2. Thank you for this piece of information. i tried adding a keyup javascript event into the textboxes i.e if something is typed into each textbox it should do something, but it work on the first textbox. Please is there a way to do this. thanks

  3. Considering how drastically the robot voice affects the quality of this video, you may want to invest in a service like Lyrebird by Descript. Something that sounds more human and less like a computer

  4. Hi,
    First thanks for the explanation, your tutorial work well, but there is one little bug, the process of adding or removing inputs doesn't respect the order of the id.
    for instance : let's assume you add an input that has id=5, for some reason you remove it and you want to add it again, the new input got the id=6 instead of 5. to fix that just add i=i-1 at the end of the code
    $(document).on('click', '.btn_remove', function() {
    var button_id = $(this).attr("id");
    i = i-1;

Leave a Reply

Your email address will not be published. Required fields are marked *