02.06.2013 Views

DOM Traversal Methods

DOM Traversal Methods

DOM Traversal Methods

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Parameters (First Version)<br />

•<br />

successful (optional): Whether to prune the included field values to<br />

successful ones. The default value is true.<br />

Parameters (Second Version)<br />

•<br />

•<br />

element: The form input element whose value is to be retrieved.<br />

successful (optional): Whether to prune the included field values to<br />

successful ones. The default value is true.<br />

Return Value<br />

An array of strings containing the field values.<br />

[ 227 ]<br />

Chapter 11<br />

Discussion<br />

The .fieldValue() method and the $.fieldValue() function both fetch the values<br />

of a form, returning them as an array of strings. The .fieldValue() method acts on<br />

a jQuery object that references individual fields, while the $.fieldValue() function<br />

performs the same task on the field element passed as its first parameter.<br />

These operations can handle fields of any standard type, such as menus:<br />

<br />

none<br />

1-5<br />

6-10<br />

11-20<br />

21-50<br />

51-100<br />

over 100<br />

<br />

The user can then select any option:<br />

The value is pulled from the currently selected option, and the .fieldValue()<br />

method will return an array representation of this value:<br />

[50]<br />

Each of the given fields shows up as a string in the array. Checkbox elements that are<br />

not checked do not get represented in the array.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!