Wednesday, May 1, 2019

Jquery Duplicate Fields Form Submit with PHP

This tutorial explains How to submit jquery duplicate/clone field values to form with PHP.  In this example we are going to provide very simple example and using existing jquery plugin, so here we are using relCopy.js jquery plugin to duplicating the existing field.

Jquery Duplicate Fields Form Submit with PHP

                                             Download                             DEMO
Lets see the below example, where we are duplicating the name field of html form.

<script type="text/javascript" src="
<script type="text/javascript" src="reCopy.js"></script>
<script type="text/javascript">
var removeLink = ' <a class="remove" href="#" onclick="$(this).parent().slideUp(function(){ $(this).remove() }); return false">remove</a>';

$('a.add').relCopy({ append: removeLink}); 

<form method="post" action="displayData.php">
<p class="clone"> <input type="text" name="name[]" class='input'/></p>
<p><a href="#" class="add" rel=".clone">Add More</a></p>
<input type="submit" value=" Submit " />



if ($_POST['name']) {
    $array = $_POST['name'];
    foreach ($array as $name) {
        if (strlen($name) > 0) {
            echo '<h2>' . $name . '<h2/>';
            // implememnt your mysql query to store data
            //$sql=mysql_query("insert into Empployee..............")

This is all about Jquery Duplicate Fields Form Submit with PHP. Thank you for reading this article, and if you have any problem, have a another better useful solution about this article, please write message in the comment section.

No comments:

Post a Comment