FORM SERIALIZATION
With the emergence of Ajax (discussed further in Chapter 21), form serialization has become a common requirement. A form can be serialized in JavaScript using the type
property of form fields in conjunction with the name
and value
properties. Before writing the code, you need to understand how the browser determines what gets sent to the server during a form submission:
- Field names and values are URL-encoded and delimited using an ampersand.
- Disabled fields aren't sent at all.
- A check box or radio field is sent only if it is checked.
- Buttons of
type
"reset"
or"button"
are never sent. - Multiselect fields have an entry for each value selected.
- When the form is submitted by clicking a submit button, that submit button is sent; otherwise no submit buttons are sent. Any
<input>
elements with atype
of"image"
are treated the same as submit buttons. - The value of a
<select>
element is thevalue
attribute of the selected<option...