Levels Tought:
Elementary,Middle School,High School,College,University,PHD
Teaching Since: | May 2017 |
Last Sign in: | 307 Weeks Ago, 1 Day Ago |
Questions Answered: | 66690 |
Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
I'm in a Web Scripting class for JavaScript and having a hell of a time with doing this question, I have tried to find similar code to break down and figure it out, but I can't seem to find any.
Here is the HTML:
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>Sales Tax Calculator</title>
<link rel="stylesheet" href="/styles.css" />Â Â
  <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> Â
<script src="/sales_tax.js"></script>
</head>
<body>
<div id="content">
<h1>Sales Tax Calculator</h1>
<p>Enter Subtotal and Tax Rate and click "Calculate".</p>
<div id="taxCalc">
<label for="subtotal">Subtotal:</label>
<input type="text" id="subtotal" >
<span id="subtotal_message">Enter order subtotal</span><br />
<label for="tax_rate">Tax Rate:</label>
<input type="text" id="tax_rate" >
<span id="tax_rate_message">Enter sales tax rate (99.9)</span><br />
<label for="sales_tax">Sales Tax:</label>
<input type="text" id="sales_tax" disabled ><br />
<label for="total">Total:</label>
<input type="text" id="total" disabled ><br />
<label> </label>
<input type="button" id="calculate" value="Calculate" >
<input type="button" id="clear" value="Clear" ><br />
</div>
</div>
</body>
</html>
and here is the JavaScript I have:
var $ = function (id) {
return document.getElementById(id);
}
var calculate_click = function () {
  var subtotal = parseFloat( $("subtotal").value );
var taxRate = parseFloat( $("tax_rate").value );
  $ salesTax (subtotal * (taxRate / 100));
  $ total (subtotal + salesTax);
 Â
 Â
}
var clear_click = function (clear) {
  return document.getElementByID(clear);
  document.getElementByID("subtotal").value = ""; // Clear Subtotal Box
  document.getElementByID("tax_rate").value = ""; // Clear Tax Rate Box
  document.getElementByID("sales_tax").value = ""; // Clear Sales Tax Box
  document.getElementByID("total").value = ""; // Clear Total Box
  $("subtotal").focus();
}
window.onload = function () {
$("calculate").onclick = calculateClick;
$("clear").onclick = clear_click;Â Â Â Â Â
$("subtotal").onclick = clearSubtotal;
  $("tax_rate").onclick = cleartax_rate;
  $("sales_tax").onclick = clearsales_tax;
$("subtotal").focus();
}
Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â----------- Th-----------ank----------- Yo-----------u f-----------or -----------usi-----------ng -----------our----------- we-----------bsi-----------te -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill-----------