OK, here's my first question for anyone who knows javascript:
I have a simple javascript exercise i completed for class and got full credit for, but I am not happy with the result.
I have a simple script that calculates a users input or "price", and adds S&H with set parameters. How do I get the window alert to display a currency format? ie: two decimal places. right now it only displays one if the other is not needed.
I'm almost positive I can use a somewhere?
Here's the script:
Code:
<script type="text/javascript">
function calcShipping(purchasePrice){
if (purchasePrice <= 25)window.alert("Your total with S&H is $" +[parseFloat(purchasePrice)+1.50]);
else window.alert("Your total with S&H is $" +[parseFloat(purchasePrice)+parseFloat(purchasePrice)*10/100]);
}
</script> Here's the form:
Code:
<form name="shippingForm" action="">
<input type="text" name="purchasePrice" />
<input type="button" value="Total with S&H" onclick="calcShipping(document.shippingForm.purchasePrice.value);" />
</form>
Any advice?