Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I'm having a hard time getting my calculator to calculate and give the alert box message. Here are my instructions and what it should look

I'm having a hard time getting my calculator to calculate and give the alert box message. Here are my instructions and what it should look like:

Can someone help me what I'm missing?

3. Code an event handler (function) named processEntries() that gets the user entries, calculates the sales tax and total, and displays those results in the text boxes. 4. Code an onload event handler that attaches the processEntries() function to the click event of the Calculate button. Then, test what you have so far. 5. Add data validation to the processEntries() function. The subtotal entry should be a valid, positive number thats less than 10,000. The tax rate should be a valid, positive number thats less than 12. The error messages should be displayed in alert dialog boxes, and the error messages should be: Subtotal must be > 0 and < 10000 Tax Rate must be > 0 and < 12 6. Add JavaScript that moves the cursor to the Subtotal field when the application starts and when the user clicks on the Calculate button. 7. Add the JavaScript event handler for the click event of the Clear button. This should clear all text boxes and move the cursor to the Subtotal field. 8. Add JavaScript event handlers for the click events of the Subtotal and Tax Rate text boxes. Each handler should clear the data from the text box.

Here is my HTML I have:

Sales Tax Calculator

Sales Tax Calculator

Enter Subtotal and Tax Rate and click "Calculate".

Here is my JS file:

var $ = function (id) { return document.getElementById(id); };

var calculate_click = function ()

{

var subtotal = parseFloat( $("subtotal").value );

var taxRate = parseFloat( $("tax_rate").value );

if(subtotal <= 0 || subtotal > 10000)

{

$("subtotal_message").innerHTML = "Must be a positive number less than $10,000";

return;

}

if(taxRate <= 0 || taxRate > 12)

{

$("tax_rate_message").innerHTML = "Must be a positive number less than 12";

return;

}

var salesTax = (subtotal * taxRate)/100;

var total = subtotal + salesTax;

$("total").value = total;

$("sales_tax").value = salesTax;

$("subtotal").focus();

}

var clear_click = function ()

{

$("subtotal").value = "";

$("tax_rate").value = "";

$("total").value = "";

$("sales_tax").value = "";

}

window.onload = function ()

{

$("subtotal").focus();

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

What is job rotation ?

Answered: 1 week ago