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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:13:05+00:00 2026-06-17T23:13:05+00:00

In my website I have an option to add (multiple times) an input with

  • 0

In my website I have an option to add (multiple times) an input with a button, using this code,

$("#add_new_detail").click(function() { 
    $("#det_add_area").append('
        <div id="no_'+i+'"><table><tr><td> '+i+' </td><td> 
            <input type="text" name="det['+i+'][details]" /> </td><td> 
            <input type="text" name="det['+i+'][amount]" value="0" /> </td><td> 
            <input type="text" name="det['+i+'][price_real]" value="0" /> </td><td> 
            <input type="text" name="det['+i+'][price_user]" value="0" /> </td><td> 
            <input type="text" name="det['+i+'][total_price]" value="0" DISABLED  /> 
            </td><td> <input type="text" name="det['+i+'][total_price_for_user]" value="0" DISABLED  /> </td><td>
            <div class="delete_line" onClick="re(\'no_'+i+'\')"> delete </div></td></tr></table></div>
  '); 
  i++; 
});

Now, every time I click the button it really creates a new line of inputs. That is working perfect.
Now I’m trying to calculate between the inputs, I’m trying to enter a number into

det[‘+i+’][amount]

and to double it with (math)

det[‘+i+’][price_real]

and to post the result in

det[‘+i+’][total_price]

now I have no idea how can I interact with these specific fields(which getting created by the button click) – every line has it own amount,price_real,total_price … how can I make this calculate with onKeyUp ?
if someone can give me an idea how am I moving on from this point I’ll be grateful.

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-17T23:13:06+00:00Added an answer on June 17, 2026 at 11:13 pm

    Here you go… I have modified the name attribute to id. Also used _ instead of [.

    Live Demo

    Whenever you change amount or price_real, the corresponding total_price will change (total_price = amount * price_real).

    jQuery

    $("#add_new_detail").on("click", function() { 
        $("#det_add_area").append('<div id="no_'+i+'"><table><tr><td> '+i+' </td><td> \
                <input type="text" id="det_'+i+'_details" /> </td><td> \
                <input type="text" id="det_'+i+'_amount" value="0" /> </td><td> \
                <input type="text" id="det_'+i+'_price_real" value="0" /> </td><td> \
                <input type="text" id="det_'+i+'_price_user" value="0" /> </td><td> \
                <input type="text" id="det_'+i+'_total_price" value="0" DISABLED  /> \
                </td><td> <input type="text" id="det_'+i+'_total_price_for_user" value="0" DISABLED  /> </td><td>\
                <div class="delete_line" onClick="re(\'no_'+i+'\')"> delete </div></td></tr></table></div>\
        '); 
    
        $("#det_" + i + "_amount").on("change", function() { 
            calculate(this); 
        });
    
        $("#det_" + i + "_price_real").on("change", function() { 
            calculate(this); 
        });
    
        i++;
    });
    
    function calculate(e) {
        j = $(e).attr('id').split("_")[1]
        total = $("#det_" + j + "_amount").val() * $("#det_" + j + "_price_real").val();
        $("#det_" + j + "_total_price").val(total);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to give one option in my website to upload multiple files and
On the website I have a button with an addClass statement. Before this button
I have a simple web service. This is consumed in a website using VS
I have the normal PayPal donation button. I want to add two multiple choice
I have website on the server, which is not precompiled (with source code, so
I have website where users can login with their Facebook account. I am using
On a website I have implemented the login using OpenID (based on StackOverflow). But
Let's suppose that we have multi-site CMS and every website in this CMS having
I have the following code below on my website. It's used to find the
I'm developing a website (using asp.net-mvc) with a SqlServer 2005 database. I have numerous

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.