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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:53:48+00:00 2026-06-15T13:53:48+00:00

I have an issue enabling functions with jQuery AutoComplete and Clone that I’m hoping

  • 0

I have an issue enabling functions with jQuery AutoComplete and Clone that I’m hoping somebody can help me with. Sorry if this is a bit over-detailed!

I have a table which has title, description, qty, price and total in it. The user can use autocomplete on the product field to fetch the title’s description and price. At the same time, I have an ‘add row’ function using clone and I’m trying to use another function to multiply the qty and price if either are changed. So far, I have the following:

Code for adding new row to table:

var $table;
$(function() {
     $table=$('#invoiceitems'); 
     var $existRow=$table.find('tr').eq(1);
      bindAutoComplete($existRow);
});

function addRow(){
    var $row=$table.find('tr:last').clone();
    var $input=$row.find('input:first');
    $row.find('input').val("");
    $row.find('#product_description').val("");
    $table.append($row);
    bindAutoComplete($row);
    $input.focus();
}

Code for AutoComplete:

function bindAutoComplete($row){
    $row.find(".product_title").autocomplete(products, {
        width: 380,
        matchContains: "word",
        formatItem: function(row) {
            return row.title;
        }
    });
    $row.find('.product_title').result(function(event, data) {
        $row.closest('.product_description').val(data.description);
        $row.find('.product_price').val(data.price);
        $row.find('.qty').val("1");
    });
}

Code for multiplying price and qty:

$(document).ready(function() {    
$(".qty, .product_price").keyup(function() {
   var $row = $(this).closest("tr"),
       price = $row.find(".product_price").val();
           qty = $row.find(".qty").val();
    $row.find(".line_total").text(qty * price);
});

At the moment, the AutoComplete and clone work fine however the multiplication for the qty and price only works on the first row and now on any new rows that are added. If I replace clone(); with clone(true); then the multiplication works however the AutoComplete does’t work properly as it updates the price on all previous rows when you use it.

I am not very good with JS and jQuery so I am hoping this is a simple mistake to correct?

Many thanks!

  • 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-15T13:53:49+00:00Added an answer on June 15, 2026 at 1:53 pm

    The problem is that clone(true) means that the data and event will also be clone.

    I would suggest that use clone() method and make the event like this

    for jQuery 1.7 and above.

    $(document).ready(function() {    
       $('table#invoiceitems').on('keyup', ".qty, .product_price", function() {
           var $row = $(this).closest("tr"),
           price = $row.find(".product_price").val();
           qty = $row.find(".qty").val();
           $row.find(".line_total").text(qty * price);
       }
    });
    

    for older versions u can use live().

    This method will be called for each new row which will be added to the table later on.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know a lot of people have had this issue, and I've seen that
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
I have an issue with jquery and history.back(): I got a link: <a href=#
I have a WCF service that is: Using the BasicHttpBinding (if you can answer
I hope someone can help me. This has been driving me crazy for days.
We have a simple datagrid that we are enabling navigation via a the tab
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
We are new to ROR, We have issue in creating Login/Logout process in ROR
Share your ideas please! I have issue to check the folder and convert a
Have an issue with marshall and unmarshall readers and writers. So here it is.

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.