Web server info - 531Chapter 23 .The Form and Related Objects Figure

531Chapter 23 .The Form and Related Objects Figure 23-1: Controls pass different object references to functions in Listing 23-1. The processData() function, which needs to read and write properties of multiple form control elements, can reference the controls in two ways. One way is to have the onClickevent handler (in the button element at the bottom of the document) call the processData() function and not pass any parameters. Inside the function, all references to objects (such as the radio buttons or the song field) must be complete references, such as document.forms[0].song.value to retrieve the value entered into the song field. A more efficient way is to send a reference to the FORM object as a parameter with the call to the function (as shown in Listing 23-1). By specifying this.formas the parameter, you tell JavaScript to send along everything it knows about the form from which the function is called. This works because formis a property of every form control element; the property is a reference to the form that contains the control. Therefore, this.form passes the value of the form property of the control. At the function, the reference to the FORM object is assigned to a variable name (arbitrarily set to formhere) that appears in parentheses after the function name. I use the parameter variable name formhere because it represents an entire form. But you can use any valid variable name you like. FORM
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Leave a Reply