Question: 5) CISC_CH9_pp346 application below Create a checkbox element on the HTML page and an associated onclick function with this control. Inside the click event associated
5) CISC_CH9_pp346 application below
Create a checkbox element on the HTML page and an associated onclick function with this control. Inside the click event associated with the checkbox, access the tip percent subtotal and the tip percentage as was done on the computetip function. Add another five percent To the tip if the checkbox is clicked, and subtract five percent from the tip if the checkbox Is not checked. Instead of using windows onload you may use defer in the link to the js file.
Tip Calculator
subtotal
PLEASE_346.js
window.onload = function(){
document.getElementById("tenpercent").onclick = computeTip;
document.getElementById("fifteenpercent").onclick = computeTip;
document.getElementById("eighteenpercent").onclick = computeTip;
};
// Computes proper tip amount based on the subtotal and tip percentage.
function computeTip() {
var subtotal = parseFloat(document.getElementById("subtotal").value);
var tipPercent = parseInt(this.innerHTML);
var tipAmount = subtotal * tipPercent / 100.0;
document.getElementById("total").innerHTML = "Tip: $" + tipAmount;
}
