Hello there,
Im creating a form table which needs to except amounts and then run the subtotals for the rows... (each row having a 'subtotal' cell at the right) And then add up the totals to a 'TOTAL' cell at the bottom of the table.
The thing is i was hoping (but it's not imperative) to have two or three fields for entry (text boxes) and then have the script perform document.write to the total cell (without a text box).
Here is the code i was trying to work with but im stuck at this point...
<code>
<script language="javascript">
function isNum(inputStr) {
for (var i = 0 ; i < inputStr.length; i++){
var oneChar = inputStr.subString( i, i + 1)
if (oneChar < "0" || oneChar > "9" ) {
alert("Please enter numbers only."
return false
}
}
return true
}
function extendRows(add) {
for (var 1 = 0; i < Qty.length; i++) {
var rowSum = form.Qty.value * form.Price.value
form.Total.value = formatNum(rowSum, 2)
}
}
</script>
</code>
... im not sure if this is the way to go. I just want it to check that all fields are number enties and then perform the calculation. But im stumped.
Could you please show me a function that will do this and how to write it to the table. It'd be much appreciated.
Thanks for the help,
DES>:O>
Im creating a form table which needs to except amounts and then run the subtotals for the rows... (each row having a 'subtotal' cell at the right) And then add up the totals to a 'TOTAL' cell at the bottom of the table.
The thing is i was hoping (but it's not imperative) to have two or three fields for entry (text boxes) and then have the script perform document.write to the total cell (without a text box).
Here is the code i was trying to work with but im stuck at this point...
<code>
<script language="javascript">
function isNum(inputStr) {
for (var i = 0 ; i < inputStr.length; i++){
var oneChar = inputStr.subString( i, i + 1)
if (oneChar < "0" || oneChar > "9" ) {
alert("Please enter numbers only."
return false
}
}
return true
}
function extendRows(add) {
for (var 1 = 0; i < Qty.length; i++) {
var rowSum = form.Qty.value * form.Price.value
form.Total.value = formatNum(rowSum, 2)
}
}
</script>
</code>
... im not sure if this is the way to go. I just want it to check that all fields are number enties and then perform the calculation. But im stumped.
Could you please show me a function that will do this and how to write it to the table. It'd be much appreciated.
Thanks for the help,
DES>:O>