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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:33:59+00:00 2026-05-30T12:33:59+00:00

First , go here: http://webapps.bcit.ca/A00839579/MDIA3207/Assign4/cart.html Basically, I would like when someone updates the quantity

  • 0

First , go here: http://webapps.bcit.ca/A00839579/MDIA3207/Assign4/cart.html

Basically, I would like when someone updates the quantity of an item it’ll update the “Sub-total” in the bottom right. Shouldn’t be too hard, but for some reason I can’t figure it out. And on a side note, if can figure out how I can keep the prices with decimals when the quantity gets updated, that’d be great too. Thanks so much!

Here’s my JavaScript:

var artprice = 28.99;
var artquantity = document.getElementById("artquantity").value;
var arttotal = (artprice * artquantity).toFixed(2) - 0;

var loverprice = 19.95;
var loverquantity = document.getElementById("loverquantity").value;
var lovertotal = (loverprice * loverquantity).toFixed(2) - 0;

var nightprice = 32.00;
var nightquantity = document.getElementById("nightquantity").value;
var nighttotal = (nightprice * nightquantity).toFixed(2) - 0;


function artupdate() {
var subtotal = arttotal + lovertotal + nighttotal;

var artprice = 28.99;
var artquantity = document.getElementById("artquantity").value;
var arttotal = (artprice * artquantity).toFixed(2) - 0;

document.getElementById("artprice").innerHTML = "$" + arttotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;
}

function loverupdate() {
var subtotal = arttotal + lovertotal + nighttotal;

var loverprice = 19.95;
var loverquantity = document.getElementById("loverquantity").value;
var lovertotal = (loverprice * loverquantity).toFixed(2) - 0;

document.getElementById("loverprice").innerHTML = "$" + lovertotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;
}

function nightupdate() {
var subtotal = arttotal + lovertotal + nighttotal;

var nightprice = 32.00;
var nightquantity = document.getElementById("nightquantity").value;
var nighttotal = (nightprice * nightquantity).toFixed(2) - 0;

document.getElementById("nightprice").innerHTML = "$" + nighttotal;
document.getElementById("subtotal").innerHTML = subtotal;
}

var subtotal = arttotal + lovertotal + nighttotal;
document.getElementById("subtotal").innerHTML = "$" + subtotal;

function isNumberKey(evt)
{
var charCode = (evt.which) ? evt.which : event.keyCode
if (charCode > 31 && (charCode < 48 || charCode > 57))
return false;

return true;
}
  • 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-30T12:34:00+00:00Added an answer on May 30, 2026 at 12:34 pm

    Here is a complete solution DEMO

    Please tell me the tax so I can add that to the script

    Note the changes to the html and to the script.

    to add new books, follow the structure you have now.

    <div id="content">
        <table border="1">
            <tr>
                <th>Book Cover</th>
                <th>Title & Author</th>
                <th>Price</th>
                <th>Quantity</th>
            </tr>
            <tr>
                <td class="image">
                    <a href="cover2.html" onClick="return openNewWindow(this.href, 475, 725);"><img alt="Book Cover" src="images/covers/2artfielding.png" /></a>
                </td>
                <td class="title">
                    <p class="table"><b>The Art of Fielding</b></p>
                    <p class="table"><i>by Chad Harbach</i></p>
                </td>
                <td class="price">
                    <p class="bookprice" id="artprice">$28.99</p>
                </td>
                <td class="quantity">
                    <input type="text" id="artquantity" value="1" /><br />
                </td>
            </tr>
            <tr>
                <td class="image"><a href="cover5.html" onClick="return openNewWindow(this.href,475, 725);"><img alt="Book Cover" src="images/covers/18thelovers.png" /></a></td>
    
                <td class="title">
                    <p class="table"><b>The Lover's Dictionary</b></p>
                    <p class="table"><i>by David Levithan</i></p>
                </td>
                <td class="price">
                    <p class="bookprice" id="loverprice">$19.95</p>
                </td>
    
                <td class="quantity">
                    <input type="text" id="loverquantity" value="1" /><br />
                </td>
            </tr>
    
            <tr>
                <td class="image"><a href="cover4.html)" onClick="return openNewWindow(this.href,475, 725);"><img alt="Book Cover" src="images/covers/11nightcircus.png" /></a></td>
                <td class="title">
                    <p class="table"><b>The Night Circus</b></p>
    
                    <p class="table"><i>by Erin Morgenstern</i></p>
                </td>
                <td class="price">
                    <p class="bookprice" id="nightprice">$32.00</p>
                </td>
                <td class="quantity">
                    <input type="text" id="nightquantity" value="1" /><br />
                </td>
    
            </tr>
            </table>
            <br />
            <p class="totals" id="subtotal">Sub-total:</p>
            <p class="totals" id="taxes">Taxes:</p>
            <p class="totals" id="grandtotal">Grand-total:</p>
    </div>
    

    JavaScript – replaces two of your js files:

    var popimage = 1;
    function openNewWindow(href, width, height) {
       // The popup name will be popup1, popup2, popup3, …. etc.   
       // Notice how we've concatenated the 'width' and 'height' parameters.
       var w = window.open(href, "popup"+popimage,
       "width=" + width + ",height=" + height +
       ",top=10,left=10,screenX=10,screenY=10,resizable=1,scrollbars=1,menubar=0");
       popimage++;
        return w?false:true;
    }
    
    var books = {}
    window.onload=function() {
      var inputs = document.getElementsByTagName('input');
      for (var i=0;i<inputs.length;i++) {
        if (inputs[i].type=="text" && inputs[i].id.indexOf('quantity')!=-1) {
          var name = inputs[i].id.replace('quantity','');
          books[name] = parseFloat(document.getElementById(name+'price').innerHTML.replace('$',''))
          inputs[i].onkeyup=function() {
            var total = 0;
            for (var book in books) {
              var q = document.getElementById(book+"quantity").value;
              total += (isNaN(q) || q=="")?0:parseInt(q)*books[book]
            }
            document.getElementById('subtotal').innerHTML="Sub-total: $"+total.toFixed(2);      
            document.getElementById('taxes').innerHTML="Taxes: $"+(total*.06).toFixed(2);      
            document.getElementById('grandtotal').innerHTML="Grand-total: $"+(total*1.06).toFixed(2);      
          }  
        }
      }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

First off here is the code! <!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
So, first off. It runs fine on another webserver: http://colorsnatcher.com/cuse/feedback.html won't work here: http://campusbasement.com/contact.php#
I'm learning Databinding from here http://www.akadia.com/services/dotnet_databinding.html I'm just updating the dataset and then updating
I want to get player lists from here: http://www.basketball-reference.com/boxscores/201105090BOS.html To do that for the
I have a user input form here: http://www.7bks.com/create (Google login required) When you first
The implementation is here: http://jsfiddle.net/chp8y/1/ If you hover over the first box, #1, you
I'm trying to use the code posted here: http://seanho.posterous.com/monotouch-first-attempt-arkit-c-version however - when i try
page here: http://webpages.marshall.edu/~glasser1/jquery.html I'm trying to replicate the old twitter page login style. If
You can easily see the problem on the first page here: http://m.vancouverislandlife.com/ Scroll down
It's my first post on here, and I'd just like to thank everyone so

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.