dwr.util.setValue(id, value)

dwr.util.setValue(id, value, options) finds the element with the id specified in the first parameter and alters its contents to be the value in the second parameter.

By default DWR protects against XSS in dwr.util.setValue by performing output escaping. The optional options object parameter allows output escaping to be disabled { escapeHtml:false }.

For example:

<span id="x"></span>

dwr.util.setValue('x', "<b>Hi</b>");

Will create a span that looks like this: <b>Hi</b>. But on the other hand, this:

<span id="x"></span>

dwr.util.setValue('x', "<b>Hi</b>", { escapeHtml:false });

Will create a span that looks like this:Hi

This method works for almost all HTML elements including selects (where the option with a matching value and not text is selected), input elements (including textareas) divs and spans.

For example:

dwr.util.setValue( , )

HTML Test Elements

A div element with id="div".
Text area (id="textarea"): Selection list (id="select"):
Text input (id="text"): Password input (id="password"):
Form button (id="formbutton"): Fancy button (id="button"):

See Also

See also setValues() and the corresponding getValue[s]() methods.