• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 11. Making Forms Perform > All Text Entries Are Strings

All Text Entries Are Strings

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> 


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint