<HTML><HEAD><TITLE>JavaScript with Forms</TITLE> |
<SCRIPT LANGUAGE="JavaScript"> |
<!-- a comment to hide JavaScript from old browsers |
function compute(form) { |
if (confirm("Is this what you want?")) |
form.result.value = eval(form.expr.value); |
else alert("Enter a new expression then!"); |
} |
// end script hiding --> |
</SCRIPT></HEAD> |
<BODY><FORM> |
Enter an expression: |
<INPUT TYPE="text" NAME="expr" SIZE=15> |
<INPUT TYPE="button" VALUE="DoIt!" ONCLICK="compute(this.form)"> |
<BR>Result: <INPUT TYPE="text" NAME="result" SIZE=15><BR> |
</FORM></BODY></HTML> |