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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:46:47+00:00 2026-05-25T09:46:47+00:00

I am building a webapp with Django which generates invoices. Each invoice has a

  • 0

I am building a webapp with Django which generates invoices. Each invoice has a list of line items with each line item having a total. Then there is a Subtotal, a Tax, and a Grand total line. The Subtotal, Tax, and Grand Total values are all calculated on the fly using jQuery. This works nicely in Chrome and Firefox, but fails in Explorer. In Explorer, only the first line item is picked up.

Here’s my little jQuery script:

<script type="text/javascript">
  $(document).ready(function() {
    var tot = 0;
    $('td#itemPrice').each(function() {
      tot = tot + parseFloat($(this).html());
      });
    $("td#sub_total_results").html(tot.toFixed(2));
    var gst = document.getElementById("gst").innerHTML;
    var tax = tot * parseFloat(gst);
    $("td#tax_results").html(tax.toFixed(2));
    var grand = tot + tax;
    $("td#grand_total_results").html("$" + grand.toFixed(2));
  });
</script>

And here is the chunk of HTML which has the line items and totals:

 <table class="lineItems_Container">
  <tr><td class="item_header" width=500 align=left>Item</td><td class="item_header" width=100 align=right>Price</td></tr>

  <tr>
    <td class="item_row">Labour</td>
    <td class="item_row" id="itemPrice" align=right>630.00</td>
  </tr>

  <tr>
    <td class="item_row">Product</td>
    <td class="item_row" id="itemPrice" align=right>75.00</td>
  </tr>

</table>
<br>
<div id="totals" style="float: right; width=200px;">
  <table class="totals_container">
    <tr>
<td class="totals_td" width=75 id="sub_total" style="font-size: 13px;">Sub Total:</td>
  <td class="totals_td" width=100 id="sub_total_results" align=right></td>
    </tr>
    <tr>
  <td class="totals_td" id="tax" style="font-size: 13px;">Tax:</td>
  <td class="totals_td"id="tax_results" align=right></td>
    </tr>

    <tr>
  <td class="totals_td" id="grand_total" style="font-size: 16px;">TOTAL:</td>
  <td class="totals_td" id="grand_total_results" align=right style="font-size: 16px;"></td>
    </tr>
  </table>
</div>

The values of 630.00 and 75.00 are brought into the template from the views.py function that calls this template.

Any ideas what is going on and why IE is only using the first line item?

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-05-25T09:46:47+00:00Added an answer on May 25, 2026 at 9:46 am

    Your HTML is invalid: you’re not supposed to have more than one element on the page with the same ID. If you do, and you try to select based on ID, you’ll get inconsistent results between browsers (as you have seen).

    You need a non-ID method of selected the itemPrice cells. One way is to make itemPrice a class rather than an ID – in this case the class wouldn’t be used to apply any styles, it is solely for easy selection from your code (in case you weren’t already of aware of it, it is perfectly legal to assign multiple classes to the same element by saying class="class1 class2 class3 etc"):

    <tr>
      <td class="item_row">Labour</td>
      <td class="item_row itemPrice" align=right>630.00</td>
    </tr>
    <tr>
      <td class="item_row">Product</td>
      <td class="item_row itemPrice" align=right>75.00</td>
    </tr> 
    
    <script>
    // select by class instead of ID
    $('td.itemPrice').each(function() {
      ...
    });
    </script>
    

    Another way to do it might be to use a selector that takes the last child of each TR.

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

Sidebar

Related Questions

I am building a webapp that has several main sections. Each section has several
I am building a webapp that has the following characteristics: It only has a
We are building a webapp which is shipped to several client as a debian
I'm building a webapp that has optional Facebook Login. The users created through the
I am building a Django powered web app that has a large database component.
I'm building a webapp with jQuery, which is using many $.get(..) and $.post(..) action-calls
I'm building a webapp that contains an IFrame in design mode so my user's
i am building a webapp that will have notes fields all over the place,
I'm attempting to mix a PHP REST framework (Recess) with an webapp building framework
I'm building a questionnaire mvc webapp, and i cant figure out how to pass

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.