Thorough explanation:
This is a DVD creation business, for personal occasions, business conferenece slideshows, school presentations etc.
For each picture they wish to use will cost them, lets say, 15p, they type the amount in, say 30 pictures, the calculation will automatically update and show the total price.
(15p*30p = £4.50 obviously)
JAVASCRIPT:
- Code: Select all
<script>
function validate(i) {
var total = document.getElementById('total');
if (!i || !i.value) {
total.innerHTML = '£0';
return false;
}
if (isNaN(i.value)) {
total.innerHTML = '£0';
document.forms[0].numPics.value = '';
alert('You must enter a valid number.');
return false;
}
var num = parseInt(i.value)*0.15;
num = num.toFixed(2);
total.innerHTML = '£'+num;
return false;
}
</script>
HTML:
- Code: Select all
<form>
<b>Enter number of pictures:</b><br>
<input type="text" onkeyup="validate(this);" name="numPics">
</form>
<br>
Your total is: <span id="total">£0</span>
However, i wish to put another text box, with a different increase value and to also determine the total price value.
How would i go about this?
Thanks in advance,
regards,
joe.


