Here is a really simplistic solution using the name feature of the input
boxes, I suggest you look in to using the Document Object Model rather then
using the name feature, for scalability.
Garrett
<html>
<head>
<title>Adding the fields</title>
<script language = "JavaScript">
<!-- hide me from old browsers
function addTheFields()
{
var x = window.document.the_form.a1.value;
var y = window.document.the_form.a2.value;
var X = x - 0
var Y = y - 0
var product = X + Y;
window.document.the_form.a3.value = product;
}
// end hiding comment -->
</script>
</head>
<body>
<form name = "the_form">
<table>
<tr>
<td><input type = "text" ID = "a1" name = "totala" onChange
"addTheFields();"></td>
<td><input type = "text" ID = "a2" name = "totala" onChange
"addTheFields();"></td>
<td><input type = "text" name = "a3"></td>
</tr>
</table>
</form>
</body>
</html>
-----Original Message-----
From: HoayFern [mailto:hoayfern.lee@d...]
Sent: Monday, November 12, 2001 3:57 PM
To: JavaScript HowTo
Subject: [javascript_howto] how to display the total hours into the text
box
Hi,
I have 3 text box called FromTime,ToTime and TheTotal text box
i also have the program to calculate the TheTotal .
what i want to do is after user key in FromTime and ToTime, the output of
TheTotal can be automtically display in the TheTotal text box and the value
of the TheTotal also must be updated into my table.
currently what i have done is ask user key in 3 field, FromTime,ToTime and
TheTotal and click submit button, then the program will check the values of
the TheTotal, if the value they key in was wrong, then the message screen
will appears and ask them to correct it.
i show it to the user and user found that it is troublesome and give
suggestions that after they key in FromTime and ToTime, the values of the
Total will be automatically appears in the TheTotal text box
can anyone offers help how can i do it
please assists
hoay fern
$subst('Email.Unsub')