- see footer for list info -<
Hi all and thatnks for the help so far. I have tinkered with all of the solutions offered but I can't seem to get them right. :-(

I now have this (I've written it in a way that I can understand if it looks real [EMAIL PROTECTED]) - Lots of google searches and code snippets from books ....


<html> <script language="javascript"><!--- messages in FORM status bar ---> <!-- function field_focus(theField) { <cfset url.nl=0>; document.getElementById('theStatus').innerHTML = theField.title; } //--> </script>

<script javascript>
<!--
function DoMath()
{
var F1 = document.frmData.FieldOne.value;
if (isNaN(F1)) F1 = 0;
var F2 = document.frmData.FieldTwo.value;
if (isNaN(F2)) F2 = 0;
var F3 = document.frmData.FieldThree.value;
if (isNaN(F3)) F3 = 0;
var F4 = document.frmData.FieldFour.value;
if (isNaN(F4)) F4 = 0;
var Total = parseFloat(F1) + parseFloat(F2) + parseFloat(F3) + parseFloat(F4);
document.frmData.Total.value = Total;
}
<!--
</script>


<form name="frmData" method="POST" >
Field One:<br>
<input type="text" onchange="DoMath()" name="FieldOne" size="20" onfocus="javascript:field_focus(this);" title="Field One"></p>
<p>Field Two:<br>
<input type="text" onchange="DoMath()" name="FieldTwo" size="20" onfocus="javascript:field_focus(this);" title="Field Two"></p>
<p>Field Three:<br>
<input type="text" onchange="DoMath()" name="FieldThree" size="20" onfocus="javascript:field_focus(this);" title="Field Three"></p>
<p>Field Four:<br>
<input type="text" onchange="DoMath()" name="FieldFour" size="20" onfocus="javascript:field_focus(this);" title="Field Four"></p>
<p>Total:<br>
<input type="text" name="Total" size="20"><br>
<span style="font-family: Arial; font-size: 8pt">
<font color="#808080">
<div id="theStatus"></div>
</span>
</form>


</body>
</html>

I Didn't use the 'for loop' as I have lots of other stuff on the form that doesn't need adding. Its just these four fields (and maybe some others further down the form).

The problem I have now is that I get NaN apperaring in the total box as I enter numbers. I found NaN on google and inserted the 'if (isNaN(F4)) F4 = 0;' which I thought would set the value to zero ...

How do I ensure that the blank (not yet input fields) are set to zero?

http://www.bgfl.org/cfpages/catering/total.cfm

Regards - Paul


_______________________________________________

For details on ALL mailing lists and for joining or leaving lists, go to 
http://list.cfdeveloper.co.uk/mailman/listinfo

--
CFDeveloper Sponsors:-
- Hosting provided by www.cfmxhosting.co.uk -<
- Forum provided by www.fusetalk.com -<
- DHTML Menus provided by www.APYCOM.com -<
- Lists hosted by www.Gradwell.com -<
- CFdeveloper is run by Russ Michaels, feel free to volunteer your help -<

Reply via email to