Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4623200
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:57:08+00:00 2026-05-22T02:57:08+00:00

I am using a simple method of cloning rows on a form. You can

  • 0

I am using a simple method of cloning rows on a form. You can see the webpage here.

This is the script I am using to do the cloning:

$(document).ready(function() {

            $(".add").click(function() {
                $("form > p:first-child").clone(true).insertBefore("form > p:last-child");
                return false;
            });

            $(".remove").click(function() {
                $(this).parent().remove();
            });

        });

and here is the form html:

    <form method="post" action="bookingengine.php">
        <p>
            <label>Full Name:</label> <input type="text" name="name" id="name">
            <label>Email:</label> <input type="text" name="email" id="email">
            <label>Telephone:</label> <input type="text" name="telephone" id="telephone">
            <span class="remove">Remove</span>
        </p>
        <p>
            <span class="add">Add fields</span><br /><br /><input type="submit" name="submit" id="submit" value="Submit" class="submit-button" />
        </p>

    </form>

There are two issues that I am having with this, which make me wonder whether cloning is the best method:

  1. If the user has already entered information into the text boxes, then these are cloned along with the text boxes themselves, and I don’t want this to happen. I would like add rows added to be empty.

  2. The information is to be submitted to an email address using PHP. Here is the PHP:

$EmailFrom =
“”;
$EmailTo = “”;
$Subject = “Booking on Retreat”; $Name
= Trim(stripslashes($_POST[‘name’])); $Email =
Trim(stripslashes($_POST[’email’]));
$Telephone =
Trim(stripslashes($_POST[‘telephone’]));

$validationOK=true; if
(!$validationOK) { print “”; exit; }

$Body = “New bookings have been made
for the Retreat as follows:”; $Body .=
“\n”; $Body .= “\n”; $Body .= “name:
“; $Body .= $Name; $Body .= “\n”;
$Body .= “\n”; $Body .= “email: “;
$Body .= $Email; $Body .= “\n”; $Body
.= “\n”; $Body .= “telephone: “; $Body
.= $Telephone; $Body .= “\n”;

$success = mail($EmailTo, $Subject,
$Body, “From: “);

if ($success){ print “”;
} else{ print “”; } ?>

What I am seeing is that only the last row in the form is being added to the email, presumably because there are not unique names or IDs for each textbox. So again I am wondering if the clone method is best suited to this task, and if it is, how I can alter my code to include all rows in the email.

Thanks,

Nick

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:57:09+00:00Added an answer on May 22, 2026 at 2:57 am

    To work with the PHP, you need to convert the inputs into ‘arrays’, by appending the 2-character sequence ‘[]’ to the end of the input’s name (see #3 on http://php.net/faq.html for more detail).

    As for cloning the objects with the values, it should be pretty simple to clear out the values in the newest added inputs as a last step of $(“.add”)’s ‘click’ handler.

        $(document).ready(function() {
    
            $(".add").click(function() {
                var x = $("form > p:first-child").clone(true).insertBefore("form > p:last-child");
                x.find('input').each(function() { this.value = ''; });
                return false;
            });
    
            $(".remove").click(function() {
                $(this).parent().remove();
            });
    
        });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Anyone know a simple method to swap the background color of a webpage using
I am posting a very simple form using a method I have used frequently
I'm using simple jQuery toggle method: $('fieldset').click(function () { $('fieldset>ul').toggle(slow); }); Is there any
I am using this simple method of finding a user in the current domain,
I'm trying to do a simple example using jQuerys fadeTo method. It works as
I have created an Ajax enabled WCF web service that contains this simple method:
how would I map this relationship in NHibernate (I'm using the simple idea of
I am using Java to build a simple method within a class that will
I have a rather annoying issue that I solved using a simple recursive method
I using simple re-size method to change my bitmap to new size. The original

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.