Example 1 - working with text input values.

Enter a number in each box and click the button.

Enter length: Enter width:



Source code

<form name="frmRectangle" action="">
  Enter length: <input type="text"
                          name="txtLength"
                          value=""
                  >
  Enter width: <input type="text"
                         name="txtWidth"
                         value=""
                 > 
               <input type="button"
                         name="btnDoArea"
                         value="Find the area"
                         onclick=" alert('Area is: ' + 
                                       parseFloat(document.frmRectangle.txtLength.value) * 
                                       parseFloat(document.frmRectangle.txtWidth.value) ); " >

</form>