I have a basic salary calculator script that I am trying to modify to my needs, and while I have some basic knowledge of Javascript, this is a tad beyond me and would greatly appreciate any assistance any one would provide.
Here is the code:
<!– TWO STEPS TO INSTALL SALARY CALCULATOR:
1.
Copy the coding into the HEAD of your HTML document
Add the last code into the BODY of your HTML document –>
<!– STEP ONE: Paste this code into the HEAD of your HTML document –>
<HEAD>
<SCRIPT LANGUAGE=”JavaScript”>
<!– Begin
function hourToYear(numHour){
if(!numHour) {
alert(“Please enter an hourly amount.”);
return;
}
if(isNaN(numHour)){
alert(numHour + ” is an invalid input. Please try again.”);
return;
}
perWeek = numHour * 40
perMonth = perWeek * 4
perYear = perMonth * 12
salaryForm.answerHour.value=”$” + toCurrency(numHour.toString());
salaryForm.answerWeek.value=”$” + toCurrency(perWeek.toString());
salaryForm.answerMonth.value=”$” + toCurrency(perMonth.toString());
salaryForm.answerYear.value=”$” + toCurrency(perYear.toString());
}
function yearToHour(numYear){
if(!numYear) {
alert(“Please enter a yearly amount.”);
return;
}
if(isNaN(numYear)){
alert(numYear + ” is an invalid input. Please try again.”);
return;
}
perMonth = numYear / 12
perWeek = perMonth / 4
perHour = perWeek / 40
salaryForm.answerYear.value=”$” + toCurrency(numYear.toString());
salaryForm.answerMonth.value=”$” + toCurrency(perMonth.toString());
salaryForm.answerWeek.value=”$” + toCurrency(perWeek.toString());
salaryForm.answerHour.value=”$” + toCurrency(perHour.toString());
}
function toCurrency(num) {
num = Math.round(num*100)/100
return num.toString();
}
// End –>
</script>
</HEAD>
<!– STEP TWO: Copy this code into the BODY of your HTML document –>
<BODY>
<form name=”salaryForm” method=”post”>
<table>
<tr><td>Enter the <b>hourly</b> amount here:</td>
<td><input name=”numHour” type=”INT” size=10 value=”0″></td>
<td><input name=”ComputeHour” value=”Compute” type=”BUTTON”
Onclick = “hourToYear(salaryForm.numHour.value)”><td>
</tr>
<tr>
<td>OR</td>
</tr>
<tr><td>Enter the <b>yearly</b> amount here:</td>
<td><input name=”numYear” type=”INT” size=10 value=”0″></td>
<td><input name=”ComputeYear” value=”Compute” type=”BUTTON”
Onclick = “yearToHour(salaryForm.numYear.value)”></td>
</tr>
<tr><td colspan=”3″><hr></td></tr>
<tr><td>Yearly:</td><td><input name=”answerYear” type=”INT” value=”0″></td></tr>
<tr><td>Monthly:</td><td><input name=”answerMonth” type=”INT” value=”0″></td></tr>
<tr><td>Weekly:</td><td><input name=”answerWeek” type=”INT” value=”0″></td></tr>
<tr><td>Hourly:</td><td><input name=”answerHour” type=”INT” value=”0″></td></tr>
</table>
</form>
What I need is for an employer to be able to obtain the cost for “x” number of people to receive flu shots. This would use a preset rate chart : Less 10 = $40 per person, 11 – 25 = $35 per person, 26 – 50 =$30 per person, 51 + = $25 per person.
Ideally, I would like the employer to just have to input the number of employees and click a Calculate Button and have the cost displayed in a form field. Ex. so if there were 7 emp. it would have to display the exact cost for 7 employees at $40 per emp. or 17 emp. calculated at $35 per emp. etc.
Any help and guidance is greatly appreciated.
Thank You Very Much.
Michelle