Updating inputs on the page

You can update inputs on the current page from a template using the JavaScript APIs getValues and setValues. In the TemplatePanel, use the <ReferencedWidget> tag, which makes the fully qualified render ID of a widget available when writing out a template.

For example:
<TemplatePanel
  renderCall="gw.web.sample.templates.SampleTemplate1.render(__writer, __escaper, colorCode)">
  <ReferencedWidget
    widget="colorCode"/>
</TemplatePanel>
Within the template itself, you can use JavaScript to update the value of the colorCode widget. For example:
gw.api.setValue("<%=colorCode%>", newValue);

When PolicyCenter renders the template panel, it replaces <%=colorCode%> with the fully qualified ID of the widget.

See also