zewkey said:
thanks trevor,
1. if the first number entered has a + (like +400,) then it would be
400/100.
2. if the first number entered has a - (like -250,) then it would be
100/250
3. that result will be multiplied by the second number entered,
which will be a posive dollar amount.
example:
i enter figure 1 (-350)----100/350 = .285
i enter figure 2 ($25)
result is $ 7.125
Try this
It requires the + or - to be entered separately. I couldn't easily get it to
accept it as one field. But perhaps this is a good idea. You can add text to
explain what the + and - mean.
The result is rounded to 3 digits and a dollar sign added. You can adjust
this as you require
<html>
<head>
<script type="text/javascript">
function calcform()
{
with (document.form1)
{ var temp = (sign.value == '+') ? number1.value/100 : 100/number1.value
result.value = '$' + Math.round(temp * number2.value * 1000)/1000 }
}
</script>
</head>
<body>
<form name="form1" action="">
Plus/Minus (enter + or - ):<br />
<input type="text" id="sign" value="+" size="1" /><br/>
Number 1 (enter number):<br />
<input type="text" id="number1" value="" size="40" /><br/>
Number 2 (enter value in dollars, e.g. 2.50) :<br />
<input type="text" id="number2" value="" size="40" /><br/>
Result:<br />
<input type="text" id="result" value="" size="40" /><br/>
<input type="button" id="Calculate" value="Calculate"
onclick="calcform()" />
<input type="reset" id="reset" value=" Clear "/>
</form>
</body>
</html>
--
Cheers,
Trevor L.
[ Microsoft MVP - FrontPage ]
MVPS Website:
http://trevorl.mvps.org/
----------------------------------------