in my introductory coding class, we are currently working on if/else statements. We do scripting within our html document, and I have provided the code I have been working on down below. I am very confused about why my information is not being outputted when I run my code. Essentially, we have to use if/else statements for if a customer purchases more than 150 clubs, and in our code we need to show an equation for if they input a number greater than 18 for cost per club. My if/else statements reflect this, and I have also checked my code for grammar mistakes but I am not finding any. Any help with this issue would be extremely appreciated! Thank you!
This part is what I have in my html:
<form id="userInformationEntry">
<p><label for="txtPutterQuantity">How many golf clubs would you like to
order:</label>
<input type="text" id="txtPutterQuantity" maxlength="100"
size="50"></p>
<p><label for="txtPutterCost">How much is the cost to be paid per golf
club:</label>
<input type="text" id="txtPutterCost" maxlength="100" size="50">
</p>
<p><label>Would you like to be added to the mailing list?</label></p>
<p><label for="radFirstChoice">Yes</label>
<input type="radio" id="chkYes" name="optionChoice1"
checked="checked"></p>
<p><label for="radSecondChoice">No</label>
<input type="radio" id="radSecondChoice" name="optionChoice2"></p>
<p><input type="button" value="Submit Order Information"
onclick="submitOrderFunction"></p>
<br>
<br>
</form>
<div id="orderInformationResults">
</div> <!--end of orderInformation div-->
This part is what I have in my script:
function submitOrderFunction() {
var golfClubAmount, golfClubCost;
var deductionAmount;
var totalAmount;
var truePrice;
var resultsString;
golfClubAmount = document.getElementById("txtPutterQuantity").value;
golfClubCost = document.getElementById("txtPutterCost").value;
golfClubAmount = parseInt(golfClubAmount);
//Only whole numbers would be enetered because you can't give half or a
quarter of a club
golfClubCost = parseFloat(golfClubCost);
//Decimals may be used if someone will be paying some change as well (ex:
$21.50)
totalAmount = (golfClubCost - 18) * golfClubAmount;
totalAmount = totalAmount.toFixed(2);
totalAmount = parseFloat(totalAmount);
//the 10% off deduction exclusively for orders of 150 clubs or more
if (golfClubAmount > 150 )
{
deductionAmount = totalAmount * .90;
}
else
{
deductionAmount = 0;
}
truePrice = totalAmount + deductionAmount;
truePrice = truePrice.toFixed(2);
//We need to limit to two decimal places
truePrice = parseFloat(truePrice);
//We will be working with decimals, so parseFloat seems like the better
function to use
resultsString = "For an order of " + golfClubAmount + " clubs, at $" +
golfClubCost + " per club, you will earn $" + truePrice + "."
document.getElementById("orderInformationResults").innerHTML =
resultsString;
}
If anyone can lead to what I am doing wrong, I would greatly appreciate it, or if anyone has any insights, thank you!