Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

JavaScript - I need to get my js file to fire when the button is clicked. I am not sure what I am doing wrong.

JavaScript - I need to get my js file to fire when the button is clicked. I am not sure what I am doing wrong.

Here is my html file:

"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

Change Calculator

Change Calculator






Here is my calculate_coins.js file:

var $ = function (id) {

return document.getElementById(id);

}

var calCents = function(){

var cents = $("myCents").value;

if(cents > 24) {

var quarters = Math.floor(cents/25);

//cents = cents%.25;

$("quarters").value = quaters

}

if(cents > 9) {

var dimes = Math.floor(cents/10);

//cents = cents%.10;

$("dimes").value = dimes;

}

if(cents > 4) {

var nickels = Math.floor(cents/5);

//cents = cents%.05;

$("nickels").value = nickles;

}

if(cents > 0) {

var pennies = Math.floor(cents/1);

$("pennies").value = pennies;

}

}

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

Students also viewed these Databases questions

Question

What was the role of the team leader? How was he or she selected?

Answered: 1 week ago

Question

What were the issues and solutions proposed by each team?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago