December 2001
Intermediate to advanced
480 pages
9h 22m
English
Another feature of form data to remember is that it treats all entries as strings. For example, in setting up an online boutique, you might want to perform math on data entered by the user. The following little script attempts to add two numbers:
<html> <head> <title> Text Box Math </title> <script language="JavaScript"> function addEmUp( ){ var sum=document.calc.aOne.value + document.calc.aTwo.value; alert(sum); } </script> </head> <body bgcolor="#ffffaa"> <h4>Enter 2 numbers and press the Sum button.</h4> <form name="calc"> <input name="aOne" type=text ><P> <input name="aTwo" type=text ><P> <input type=button value="Sum" onClick="addEmUp( )"> </form> </body> </html>
When you run the script, you will see, as ...
Read now
Unlock full access