?In this assignment 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:
Please find the js code ::::
----------------------------------------------
var $ =function(id){
return document.getElementById(id);
}
function convertData(){
cents = $("cents").value;
cents = parseInt(cents);
noOfQ = parseInt(cents/25);
cents = cents%25;
noOfD = parseInt(cents/10);
cents = cents%10;
noOfN = parseInt(cents/5);
cents = cents%5;
noOfP = cents;
$("quarters").value = noOfQ;
$("dimes").value = noOfD;
$("nickels").value = noOfN;
$("pennies").value = noOfP;
}
need to assign this function call to onclick of button
so modify and add onclick to the button in html like below:
<input type="button" value="Calculate" id="calculate" onclick="convertData()">
output:
?In this assignment you will use the onclick event for a form button to make calculations...