Hi,
I'm trying to make a simple script, which updates a TotalCost field (which is readonly)
The code is as follows:
Basically, the problem is - the ALERT box is showing me:
400100
(i.e 400 + 100, but not numberial - as I need :/)
Can anyone advise me where I'm going wrong? Working with numbers in JS is a little new to me (only just getting to graps with the basics =))
TIA!
Andy
I'm trying to make a simple script, which updates a TotalCost field (which is readonly)
The code is as follows:
Code:
<head>
<meta http-equiv="Content-Language" content="en-gb">
<script>
function updateTotal() {
if(document.purchase.Service1.checked) {
var new_price = document.purchase.TotalAmount.value + 100;
alert('its ticked - value' + new_price);
}
}
</script>
</head>
<form name="purchase" method="POST" action="--WEBBOT-SELF--">
<p>Base cost: </p>
<p><input type="text" name="TotalAmount" value="400" readonly="yes" size="20"></p>
<p><input type="checkbox" name="Service1" value="Yes" oncheck="updateTotal();"> Service 1 - $100</p>
<p> </p>
<p> </p>
<p><input type="submit" value="Submit" name="B1"><input type="reset" value="Reset" name="B2"></p>
</form>
Basically, the problem is - the ALERT box is showing me:
400100
(i.e 400 + 100, but not numberial - as I need :/)
Can anyone advise me where I'm going wrong? Working with numbers in JS is a little new to me (only just getting to graps with the basics =))
TIA!
Andy