Glenn Abelson
asked on
simple java math script needed
I am NOT a php or java programmer. I am looking for a complete solution.
I need script that asks a question like "What do you charge for blah blah"
The user enters a dollar amount.
The script then does math based on the number entered.
The script math is a number I hard code into the script/user entered number.
Example:
User enters 125
My hard coded number is 250
Math would be 250/125
The script would then return: "Your result (or words that I would put in) is " 2 (the result of the math)
thanks.
I need script that asks a question like "What do you charge for blah blah"
The user enters a dollar amount.
The script then does math based on the number entered.
The script math is a number I hard code into the script/user entered number.
Example:
User enters 125
My hard coded number is 250
Math would be 250/125
The script would then return: "Your result (or words that I would put in) is " 2 (the result of the math)
thanks.
Homework?
Ha, that's what I was thinking Badotz.
Anyway, I'll help out:
Anyway, I'll help out:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script type="text/javascript">
function SimpleMath()
{
var num = document.getElementById('userNumber').value;
num = num != '' ? num : 0;
document.getElementById('result').innerHTML = 250 / num;
}
</script>
</head>
<body>
<span>Enter a number:</span>
<input id="userNumber" type="text" />
<br />
<a href="Javascript:SimpleMath()">Click Me</a>
<br />
<span>Your Result: </span>
<span id="result" />
</body>
</html>
ASKER
No...homework ended decades ago.
I am a retired computer systems engineer.
I am a retired computer systems engineer.
ASKER
That works fine, thanks.
I would like to round the decimals to 2, however.
I would like to round the decimals to 2, however.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.