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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T02:21:14+00:00 2026-06-16T02:21:14+00:00

I have this bit of code – works perfectly $(‘.canti,.precio’).change(function() { var total =

  • 0

I have this bit of code – works perfectly

$('.canti,.precio').change(function() {
 var total = 0;
 var $item = $(this).parent();
 var canti = $item.find(".canti").val();
 var precio = $item.find(".precio").val();  
 total = parseFloat(canti * precio); 
 $item.find(".subto").attr("value", total); 
});

it makes calculations based on a field set

<fieldset class="item">
<input name="item[]" type"text" value="" />
<input class="canti" name="cantidad[]" type"text" value="" />
<input class="precio" name="preciounitario[]" type"text" value="" />
<input class="subto" name="importe[]" type"text"value="" readonly="readonly"/>
</fieldset> 

I had multiple actual fieldsets and it worked perfectly. However rather than initially having X fieldsets I wanted the user to be able to add as they required, so wrote this:

var newFieldset='<fieldset class="item"><input name="item[]" type"text" value="" /><input class="canti" name="cantidad[]" type"text"  value="" /><input class="precio" name="preciounitario[]" type"text"  value="" /><input class="subto" name="importe[]" type"text"value="" readonly="readonly"/></fieldset>'
$(".add").click(function(){
    $(".add").before(newFieldset);
});

Again – works perfectly and adds in a new fieldset BUT the calculations on the .canti and .precio items in the new “virtual” fieldsets don’t do anything.

Any ideas? Is what I’m hoping to do even possible?

There’s a more complete version at http://www.cristalyaluminiodiestro.com/estimate-create-testing

  • 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-16T02:21:16+00:00Added an answer on June 16, 2026 at 2:21 am

    Need to delegate the Event

    You can use the jQuery .on() method

    $('body').on('change','.canti,.precio' ,function() {
    

    That is because the way you are adding the events will not work for dynamically created elements

    ‘body’ can be replaced with the closest static parent container..

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

Sidebar

Related Questions

ok i got this problem. i have this routes: (code bit change) File:/home/dotcloud/current/config/routes.js exports.routes
I have the following bit of code, simply: $(function() { $('a.add-photos-link').live('click', function(e) { $(this).colorbox({
I have this bit of code: var has_logger = (window.console && window.console.log); if (has_logger)
I currently have this bit of code: $(.usericon).hover(function () { if ($(.profile).is(:hidden)) { $(.profile).slideDown('slow');
I have this bit of code, which works: val directions = rs.map(_.direction) // Direction
I have this bit of code: ... var aData = request.responseXML.getElementsByTagName('data')[0]; var sDescription =
So I have this existing bit of code that compiles perfectly in Visual Studio
$(#add_activity).click(function () { $('#activities').append('@Html.Raw(Html.Partial(MyPartial).ToHtmlString())'); }); I have this bit of code that seems to
I have this bit of code: function addEmail() { email = $(#email).val(); atime =
Possible Duplicate: execute a function only once i have this bit of code and

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.