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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:23:44+00:00 2026-05-24T05:23:44+00:00

I have a datagrid where I have cell Quantity and another one Price with

  • 0

I have a datagrid where I have cell Quantity and another one Price with a label at the end showing the result (price * qty). That’s work perfectly. But I can also delete a row and thats when it stop working.

This is my code

http://jsfiddle.net/bizonbytes/SYwpy/24/

To replicate the problem:

  1. enter numbers in each rows (you will see the result of price *
    qty)
  2. Then delete row 2
  3. now go to row 1 and you change the
    value and you will see the result but if you do it on row 3 it won’t
    work

So my question is why Row 3 stop working.

As a business req I need to rename the id’s to 1 and 2 and not leaving them to 1 and 3

HTML is:

<div class="row_table row_service_table" id="service_row_1">
    <div class="cell celldata cell_service_data"><input type="text" class="quantity_row" id="quantity_row_1" rel="1"/></div>
    <div class="cell celldata cell_service_data"><input type="text" class="price_row" id="price_row_1" rel="1"/></div>
    <div class="cell celldata cell_service_data"><a href="javascript:void(0)" class="delete_service_row" id="delete_service_row_1" rel="1">Delete row 1</a></div>
    <div class="cell celldata cell_service_data">Result row 1=<span id="total_1"></span></div>
</div>

etc.

Javascript:

$(".delete_service_row").click(function(){
    var rowId = $(this).attr('rel');

    $('#service_row_' + rowId).remove();

    // iterates through each of the elements matched by the selector
    $('.row_service_table').each(
        // i represents the index of each of the elements
        function(i){
              // sets the id of each of the returned elements
              // to the string concatenated with the expression 'i + 1'
            this.id = 'service_row_' + (i+1);

            $(this).children('.cell_service_data').children('.quantity_row').attr('id', 'quantity_row_' + (i+1));
            $(this).children('.cell_service_data').children('.quantity_row').attr('rel', (i+1));
            $(this).children('.cell_service_data').children('.quantity_row').attr('name', 'quantity_row_' + (i+1));

            $(this).children('.cell_service_data').children('.price_row').attr('id', 'price_row_' + (i+1));
            $(this).children('.cell_service_data').children('.price_row').attr('rel', (i+1));
            $(this).children('.cell_service_data').children('.price_row').attr('name', 'price_row_' + (i+1));
      });
});

$('.quantity_row,.price_row').live('change', function(){
    var rowId = $(this).attr('rel');

    // Lets update the total line
    var total = parseFloat($('#quantity_row_' + rowId).val()) * parseInt($('#price_row_' + rowId).val());
    $('#total_' + rowId).text(total);
});
  • 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-24T05:23:44+00:00Added an answer on May 24, 2026 at 5:23 am

    You’re remapping the ids and rels of the two inputs, but leaving the id of the result span untouched! (Also not changing the text of the containing div.)

    See this fiddle that renumbers everything.

    The changes were:

    1. Added <span class="rezLabel"> to the results row and gave the result-value span a class of rezValue.
    2. Changed the renumbering code to:

      $('.row_service_table').each (
          // i represents the index of each of the elements
          function(i){
                // sets the id of each of the returned elements
                // to the string concatenated with the expression 'i + 1'
              this.id         = 'service_row_' + (i+1);
              var baseNode    = $(this).children('.cell_service_data');
      
              baseNode.children('.quantity_row').attr('id', 'quantity_row_' + (i+1));
              baseNode.children('.quantity_row').attr('rel', (i+1));
              baseNode.children('.quantity_row').attr('name', 'quantity_row_' + (i+1));
      
              baseNode.children('.price_row').attr('id', 'price_row_' + (i+1));
              baseNode.children('.price_row').attr('rel', (i+1));
              baseNode.children('.price_row').attr('name', 'price_row_' + (i+1));
      
              baseNode.children('a').text('Delete row ' + (i+1));
              baseNode.children('a').attr('id', 'delete_service_row_' + (i+1));
              baseNode.children('a').attr('rel', (i+1));
      
              baseNode.children('.rezLabel').text('Result Row ' + (i+1) + ' = ');
              baseNode.children('.rezValue').attr('id', 'total_' + (i+1));
      } );
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to access the value that underlies the active cell of a DataGrid
I have a DataGrid (the official one) with SelectionUnit=Cell . When the user selects
I have some 6 columns in Silverlight 4 Datagrid. On each cell in the
I want my datagrid columns to share a cell/celledit template. I have the solution
I have a DataGrid component that displays a few columns of data. It has
I have a datagrid column with a button that opens a modal dialog box
I am making a WPF-application.I have a datagrid with a column header that contains
I have a DataGrid in a WPF application that binds itself to an ObservableCollection
I have a DataGrid with a NumericStepper as the item editor for one of
I have a DataGrid and it has a DataGridTextColumn that has items which I

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.