539Chapter 23 .The Form and Related Objects consisting (Photography web hosting)

539Chapter 23 .The Form and Related Objects consisting of three entries (one for each item in source code order). Each entry is a valid reference to that element; so, to extract properties or call methods for those elements, your script must dig deeper in the reference. Therefore, if the first element of a form is a text field and you want to extract the string currently showing in the field (a text element s valueproperty), the reference looks like this: document.forms[0].elements[0].value Notice that this reference summons two array-oriented properties along the way: one for the document s forms property and one for the form s elementsproperty. In practice, I suggest you refer to form controls (and forms) by their names. This allows you the flexibility to move controls around the page as you fine-tune the design, and you don t have to worry about the source code order of the controls. The elements array comes in handy when you need to iterate through all of the controls within a form. If your script needs to loop through all elements of a form in search of particular kinds of elements, use the typeproperty of every form object (NN3+ and IE4+) to identify which kind of object it is. The type property consists of the same string used in the TYPE attribute of an tag. Overall, I prefer to generate meaningful names for each form control element and use those names in references throughout my scripts. The elements array helps with form control names, as well. Instead of a numeric index to the elements array, you can use the string name of the control element as the index. Thus, you can create a generic function that processes any number of form control elements, and simply pass the string name of the control as a parameter to the function. Then use that parameter as the elementsarray index value. For example: function putVal(controlName, val) { document.forms[0].elements[controlName].value = val } If you want to modify the number of controls within a form, you should use the element and/or node management facilities of the browser(s) of your choice. For example, in IE4+ and NN6+, you can assemble the HTML string for an entirely new set of form controls and then assign that string to the innerHTML property of the FORM element object. On the CD-ROM Example (with Listing 23-2 and Figure 23-2) on the CD-ROM Related Items: text, textarea, button, radio, checkbox, and select objects. encoding enctype Value: MIME Type String Read/Write (see text) NN2 NN3 NN4 NN6 IE3/J1 IE3/J2 IE4 IE5 IE5.5 Compatibility . . . FORM.encoding
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Leave a Reply