1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
|
<html>
<head>
<title>My Untitled Document</title>
<script type="text/javascript" language="javascript">
<!--
function calcVals() {
var form = document.form1;
var total = document.getElementById("valTotal");
var currentTotal = total.value.replace('$','');
// document.pgCartOrder.calculatedTotal.value='0';
var tempTotal = 0;
var totalFields = eval(form.elements.length-1);
//alert (totalFields);
for (i=0; i < totalFields; i++) {
if(form.elements[i].type == 'submit'){
}else if(form.elements[i].type == 'text'){
if(form.elements[i].value > 0){
tempTotal = tempTotal + parseFloat(form.elements[i].title * parseInt(form.elements[i].value));
}else if(form.elements[i].value = 'NaN'){
form.elements[i].value = "";
}
}
}
if (String(total) != 'NaN') {
form.valTotal.value = "$"+ tempTotal;
} else {
form.valTotal.value = 'ERROR';
}
}
form.valTotal.value = round(form.valTotal.value, 2);
-->
</script>
</head>
<body onload="calcVals()">
<? if ($_POST['send']){ ?>
<? echo floor($_POST['textfield']) ;?>
<? echo "<br>";?>
<? echo floor($_POST['textfield1']) ;?>
<? echo "<br>";?>
<? echo floor($_POST['textfield2']) ;?>
<? echo "<br>";?>
<? } ?>
<form id="form1" name="form1" method="post" action="" >
$ 9.25<input type="text" name="textfield" value="1" title="9.25" onkeyup="calcVals();"/><br/>
$12.25<input type="text" name="textfield1" title="12.25" onkeyup="calcVals();"/><br/>
$ 5.00<input type="text" name="textfield2" title="-5.00" onkeyup="calcVals();"/><br/>
<input type="text" readonly="" name="valTotal" id="valTotal" value="$0"/>
<input type="submit" name="send" value="SEND" />
</form>
</body>
</html> |
Partager