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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T11:00:24+00:00 2026-05-29T11:00:24+00:00

I cannot seem to figure out where I went wrong with this. favorite share

  • 0

I cannot seem to figure out where I went wrong with this.

favorite
share [g+] share [fb] share [tw]

I’m creating a website as a small store for personal use, my main question here is how would I code a function for the additon of all of it?

six single check boxes for various types of peripheral devices including printer, monitors, modems or other devices with which you are familiar. Assume the basic computer system price of $500.00 and then add appropriate prices based on user checks.
Monitor 299.99 Printer 129.99 Speakers 49.99 CDRW 159.99 Scanner 129.99 Modem 49.99

If I add just a scanner, my total will be $629.99. If I add a modem and a monitor, my total will be $849.98.

I may be overlooking something simple. When I click a checkbox, it does not add to the total like it’s supposed to.

<html>
<head>
<title>Problem 9</title>
<script type="text/javascript" src="code.jquery.com/jquery-1.7.1.min.js"></script>
<script type="text/javascript">
$(function() {
  function calculateCost() {
    var ret = 500;
    var $selected = $('input:checked', $peripherals);

    $selected.each(function() {
      ret += parseFloat($(this).attr('alt'));
    });

    return ret.toFixed(2);
  }

  function setCost() {
    $total.text(calculateCost());
  }

  var $peripherals = $('#peripherals');
  var $total = $('#total');
  $('input[type="checkbox"]', $peripherals).on('change', setCost);

  setCost();

});

</script>
<body>
<h1>What peripherals do you want to add?</h1>
<form id="peripherals">
    <input type="checkbox" name="Monitor" value="Monitor" alt="299.99">Monitor<br>
    <input type="checkbox" name="Printer" value="Printer" alt="129.99">Printer<br>
    <input type="checkbox" name="Speakers" value="Speakers" alt="49.99">Speakers<br>
    <input type="checkbox" name="CDRW" value="CDRW" alt="159.99">CDRW<br>
    <input type="checkbox" name="Scanner" value="Scanner" alt="129.99">Scanner<br>
    <input type="checkbox" name="Modem" value="Modem" alt="49.99">Modem<br>
</form>
<p>Total cost:<span id="total">0</span></p>
</body>
</html>
  • 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-29T11:00:24+00:00Added an answer on May 29, 2026 at 11:00 am

    Looking at the JavaScript console, I bet it would have an error about $ not being defined. It is because you are not linking to the jQuery js file correctly.

     <script type="text/javascript" src="code.jquery.com/jquery-1.7.1.min.js"></script>
    

    It is looking for it on your domain, not jQuery’s

     <script type="text/javascript" src="//code.jquery.com/jquery-1.7.1.min.js"></script>
    

    notice that I added the //

    JSFiddle

    If you are running this off the file system and not a server, you need to add http://

     <script type="text/javascript" src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
    

    So it will use the right protocol to fetch the file or just download the file and link to it locally.

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

Sidebar

Related Questions

I cannot seem to figure out what is making this script go wrong... You
I cannot seem to figure out I am getting the following error in IE
I am getting very frustrated because I cannot seem to figure out why Collections
Ok sorry this might seem like a dumb question but I cannot figure this
I cannot seem to figure out how to do a Selection Alignment in the
I cannot seem to figure out how to dynamically change the selected item in
i am currently using the RestClient and cannot seem to figure out how to
I have a syntax error in this subquery that I cannot seem to figure
I am new to ExtJS and cannot seem to figure out how to group
I have a particular need which I cannot seem to figure out. I've done

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.