setValues

sets values for all inputs in the component

void setValues(object values, [boolean update] );

Parameters

valuesobjecthash of property - value pairs
updatebooleanif true adds updates the form with new values while exisitng values remain. **False by default**

Example

function set_form(){
    $$('myform').setValues({
            field_a: "London", 
            field_b: "New York"
            });
    };

Related samples

Details

The setValues method called only with the first parameter changes all values, regardless the values specified in the first parameter. The first parameter is an object with "key-value" pairs. Where key is a name of the form field, and value is the new value for the field.

$$('myform').setValues({
    field_a: "London", 
    field_b: "New York"
});

If the form had fields other than the two specified in the object, their values will be reset. To avoid this and to update the specified fields only, pass the second parameter true to the setValues method.

$$('my_form').setValues({ field_b:"Paris" }, true);
// only field_b will be updated
See also
Back to top