Passing Data Between Forms and Variables

Before going on to discuss arrays, you need to understand the relationship that exists between HTML form properties and variables and values in JavaScript. You should understand something about passing data between forms and JavaScript variables. Consider the following form in an HTML page:

<html> 
<body bgcolor=#BedFed> 
<form name = "stateBird"> 
      <input type="text" name="state"> 
      <input type="text" name="bird"> 
</form> 
</body> 
</html> 

The form itself is treated as an object in JavaScript, and, as was seen in previous chapters, objects are one of the data types that you can put into a JavaScript variable. The general format for using form data to a JavaScript variable is shown here:

						var variableName = ...

Get JavaScript Design now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.