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 8568553
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T18:08:17+00:00 2026-06-11T18:08:17+00:00

JQUERY <script type=text/javascript src=jquery-1.5.1.min.js></script> <script type=text/javascript> $(‘#aggiungi’).live(‘click’, function(){ var thisRow = $(this).parent().parent(); // clone

  • 0

JQUERY

 <script type="text/javascript" src="jquery-1.5.1.min.js"></script>
    <script type="text/javascript">
            $('#aggiungi').live('click', function(){
            var thisRow = $(this).parent().parent();

            // clone and add data
            thisRow.clone(true).insertAfter(thisRow).data('is_clone',true);
            $(this).val("-");
            $(this).attr("id","remove");

            var nextRow = thisRow.next();
            nextRow.find('input:not(#aggiungi)').val("");

            if (thisRow.data('is_clone')){
                while(thisRow.data('is_clone')){
                    thisRow = thisRow.prev();
                }
            }else{
                nextRow.children(":first").remove();
            }

            currRowSpan = thisRow.children(":first").attr("rowspan");
            thisRow.children(":first").attr("rowspan", currRowSpan+1);
        });

        $('#remove').live('click', function(){
            var thisRow = $(this).parent().parent(),
                prevRow = thisRow.prev();

            if (thisRow.data('is_clone')){
                while(prevRow.data('is_clone')){
                    prevRow = prevRow.prev();
                }
            }else{
                prevRow = thisRow.next()
                                 .removeData('is_clone')
                                 .children(":first")
                                 .before(thisRow.children(":first"))
                                 .end();
            }

            currRowSpan = prevRow.children(":first").attr("rowspan");
            prevRow.children(":first").attr("rowspan", currRowSpan-1);
            thisRow.remove();
        });


    </script>

PHP

        <form action="grading.php" method="post">              
                              <table width-"100%" id="tableRealizzazione">
                                <tr>
                                    <th></th>
                                    <th style="padding:12px;text-align:center;">Personale</th>
                                    <th style="padding:12px;text-align:center;">Percentage</th>
                                    <th style="padding:12px;text-align:center;">Marketing point</th>
                                    <th style="padding:12px;text-align:center;">Add/Remove</th>
                                </tr>'; 

    echo '<tr class="even">
                                          <td></td>
                                          <td style="padding:12px;"><input type="text" value="" id="Personale" name="Personale"></td>
                                          <td style="padding:12px;">
                                            <input type="text" id="from" name="from" size="5%"> -
                                            <input type="text" id="to" name="to" size="5%"> %
                                          </td>
                                          <td style="padding:12px;"><input type="text" class="totaliCostiGestione" id="marketpt" name="marketpt"></td>
                                          <td style="padding:12px;"><input type="text" name="programid" value ="34" size="10%"></td>
                                          <td style="padding:12px;"><input type="button" value="+" id="aggiungi"/></td>';         
                                   echo '</tr>';
 echo '<tr><td><input type="submit" name="submit" value="submit"></td></tr>';                      
                 echo '</table>
               </form>

When I fill the values of all text boxes and click submit, it prints only the last row and the the last row with value 34 not repeating for all the rest rows.

Here is my code in Fiddle
http://jsfiddle.net/gansai/PA9JF/

  • 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-06-11T18:08:18+00:00Added an answer on June 11, 2026 at 6:08 pm

    That is because you have to make arrays from your form:

    eg:

    <input type="text" id="from" name="from[]" size="5%"> -
    

    to clone values you have to add:

    newRow = thisRow.clone(true).insertAfter(thisRow).data('is_clone',true);
    $(newRow+"[name^=programid]").val($(thisRow+"[name^=programid]").val());
    

    Like this JSFiddle

    then in PHP:

    foreach($_POST['marketpt'] as $num => $val){
        $Personale = $_POST[$num]['Personale'];
        $from = $_POST[$num]['from'];
        $to = $_POST[$num]['to'];
        $marketpt = $_POST[$num]['marketpt'];
        $programid = $_POST[$num]['programid'];
        // process variables, eg: insert in database
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

#!/usr/bin/perl print Content-type: text/html \n\n; print qq(<html> <head> <script type=text/javascript src=/jquery.js></script> <script> jQuery(document).ready(function(){ jQuery(#form_lang).submit(function(e){
<script type=text/javascript> if (typeof jQuery == 'undefined') { var script = document.createElement('script'); script.type =
I have a jQuery script: $.ajax({ url: /scripts/secure/development/ajax.asp, type: POST, dataType: text, data: cmd=addresses,
I have this jQuery script var dataString = class_id=+class_id; $.ajax({ type: POST, url: page.php,
<!DOCTYPE html> <html lang=en> <head> <meta http-equiv=Content-Type content=text/html; charset=utf-8> <script src=http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js type=text/javascript></script> <script type=text/javascript>
I have the following jquery script: $(function(){ $('#top-menu').on('click', 'a.change-menu', function(e){ e.preventDefault() $(#menu-change-div).load($(this).attr(href)); }); });
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I use jQuery on my website like this: <head> <script src=http://ajax.googleapis.com/.../jquery.min.js ...></script> </head> I
When using an importjs() type of function (see below for an example), jQuery doesn't
I am referencing the jQuery library, in a master page like so: <script type

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.