Question: using JavaScript In this program you will use the onclick event for a form button to make calculations based on the user input. Below is
using JavaScript
In this program you will use the onclick event for a form button to make calculations based on the user input. Below is a screen capture of your expected output. Don't forget to download the assignment data files posted below.
HINT: To extract the user input from a form element, try: var cents = document.getElementById("myCents").value if "myCents" is the value assigned to the ID attribute for the HTML input element that is uded to create the text box where the user enters thier number. Example: .
Operation
This application allows the user to enter a number of cents from 0 to 99.
When the calculate button is clicked (the event), this application displays the fewest number of coins for each denomination needed to add up to the amount of cents entered by the viewer.
default.css
body {
font-family: Arial, Helvetica, sans-serif;
background: #666666;
}
#content {
width: 600px;
margin: 10px auto;
padding: 5px 20px;
background: #FFFFFF;
border: 1px solid #000000;
}
h1 {
text-align: center;
}
label {
display: block;
width: 15em;
text-align: right;
padding-right: 1em;
float: left;
}
input {
display: block;
width: 15em;
float: left;
}
br {
clear: left;
}
#calculate {
width: 6em;
margin-left: 1em;
}
.disabled {
color: #000000;
}
calculate.js
var $ = function (id) { return document.getElementById(id); }
index.html
| /td> | |
| "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | |
Change Calculator | |
| |
| |
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
