Forms

For fields, you can't use update(). Use $('element').value = var;

Use $F to get values, not set them

Two ways to get the values: $F('element') or $('element').getValue()

Contents:

Contents:

Checkbox Status:

Resetting Form

This seems a little odd, but to reset a form, use $('form').reset(); (instead of $F)

  Add Text   Reset Form

JSON Object and String

For submitting a form using Ajax.Request, you send the parameters as a JSON Object.

Again, do not use $F(element). Use $(element) with serialize().

The getHash argument will make it return a Javascript object, not a Prototype one.

To get a string, the element must be cast as a Hash or an Object first.

Object.toJSON(element);

$H(element).toJSON();

Select Menus / Dropdowns

Getting the value attribute of the option is simple. Just use $F({select id}) as normal.

There are two ways to set the selected index. One is to set the value of the attribute to the option value directly, if you know the key.

The other way is to set the selectedIndex, using the indexed key.

Notes