<HTML>
<Head>
<Title> untitled </title>
<Style type = "text/CSS">
Input {width: 40px ;}
</Style>
<SCRIPT type = "text/JavaScript" Language = "JavaScript">
Function autocalc (E)
{
VaR field, Val, total = 0, I = 0;
For (I; I <arguments. length; ++ I) // loop through text elements
{
Field = arguments [I];
Val = parsefloat (field. Value); // get value
If (! Isnan (VAL) // number?
{
Total + = val; // accumulate
}
}
E. Form. Total. value = total; // out
}
Function ensuredecimal (E)
{
If (event. keycode <48) | (event. keycode> 57) & (event. keycode! = 46 ))
{
Event. returnvalue = false;
}
Else if (E. value. indexof ('.')! =-1) & event. keycode = 46)
{
Event. returnvalue = false;
}
}
</SCRIPT>
</Head>
<Body onload = "document. Forms [0]. Reset ()">
<Form>
<Table cellspacing = "8">
<Tr>
<TD> value 1: <input name = "text1" type = "text" onkeypress = "ensuredecimal (this)" onkeyup = "Return autocalc (this, text2, text3) "tabindex =" 1 "> </TD>
<TD rowspan = "3"> <strong> total: </strong> <input name = "Total" type = "text" readonly = "readonly" value = "0" tabindex = "-1"> </TD>
</Tr> <tr>
<TD> value 2: <input name = "text2" type = "text" onkeypress = "ensuredecimal (this)" onkeyup = "Return autocalc (this, text1, text3) "tabindex =" 2 "> </TD>
</Tr> <tr>
<TD> value 3: <input name = "text3" type = "text" onkeypress = "ensuredecimal (this)" onkeyup = "Return autocalc (this, text1, text2) "tabindex =" 3 "> </TD>
</Tr>
</Table>
</Form>
</Body>
</Html>