## Friday, January 2, 2009

### Creating a Web Form - Lesson 2

Let's take the simple interactive hypotenuse calculator from the previous post and create a version of it that has a couple of fields and a button to do the computation:
[displayAll]
cls
print "Hypotenuse Calculator"
print
print "Length of side A: ";
textbox #sideA, a
print
print "Length of side B: ";
textbox #sideB, b
print
button #go, "Go!", [go]
print
if c > 0 then print "Length of side C: "; c
wait

[go]
a = #sideA value()
b = #sideB value()
c = sqr(a^2+b^2)
goto [displayAll]
The first part of the program clears the web page using the CLS statement. Then it adds labels and entry fields using the PRINT and TEXTBOX statements.

Then the BUTTON statement adds a button that will use the code at the [go] label to compute the length of the C side.

Notice the IF THEN statement after the BUTTON statment. If the length of C is greater than zero then that means we have computed at least once, so print the result on the web page.