subhailc
07-07-2004, 12:02 AM
hi. i have forgotten what little i once knew of js. trying to write a function that sets 2 variables which are the product of 2 text input form fields, and performs a single simple formula either onlostfocus or onmouseout or onclick of something (anything), then displays the answer either via an alert box or just document.write
solely for clarification, here's a hamfisted psuedo-script:
<html>
<head>
<script>
var a = form1.field1.value;
var b = form1.field2.value;
function calc(); {
document.write = ('(((((a*a)*a)/((b+1)-a))*a)+(100/b))/2)');
}
</script>
</head>
<body>
<form id="form1" name="form1" method="getblahblah">
<input type="text" name="field1" size="2" id="field1" value="1" onlostfocus="calc()";>
<input type="text" name="field2" size="2" id="field1" value="1"
onlostfocus="calc()";>>
</form>
</body>
</html>
solely for clarification, here's a hamfisted psuedo-script:
<html>
<head>
<script>
var a = form1.field1.value;
var b = form1.field2.value;
function calc(); {
document.write = ('(((((a*a)*a)/((b+1)-a))*a)+(100/b))/2)');
}
</script>
</head>
<body>
<form id="form1" name="form1" method="getblahblah">
<input type="text" name="field1" size="2" id="field1" value="1" onlostfocus="calc()";>
<input type="text" name="field2" size="2" id="field1" value="1"
onlostfocus="calc()";>>
</form>
</body>
</html>