|
I have a very small javascript function, where I want to multiply a "quantity" with the item's price and add a postage charge if quantity is less than 3 items, and finally display a total amount. Quantity is the only user input. When I placed this code inside a table on my webpage I could not get it to display the total amount; it does work if used on a webpage without tables... WHY??!
Notes: I'm using FrontPage for the webdesign; is that what's causing the problem??
This is the script:
<SCRIPT language = JavaScript>
function calculate()
{
var quant = document.orderfrm.txtqty.value
var quantity = Number(quant)
var postage = 0.50
var price = 3.99
if (quantity < 3)
{
var finalprice = (price + postage) * quantity
}
else
{
var finalprice = quantity * price
}
document.orderfrm.txtamount.value = finalprice
}
</SCRIPT>
|
|
and this is where it's called (I left out formatting code for clarity):
<input type="text" name="txtqty">Total Order Price:
<input type="button" value="update" name="b1" onClick = calculate()>
<input type="text" name="txtamount" size="5" value="">
|
|
<Added>
<b>I apologise... Gremlins made me post this into the wrong forum! Sowwy...</b>
|
|
|
|
|
|
|
// |