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