<?xml version="1.0"?>
<!--
  Copyright 1999-2004 The Apache Software Foundation

  Licensed under the Apache License, Version 2.0 (the "License");
  you may not use this file except in compliance with the License.
  You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<page xmlns:ft="http://apache.org/cocoon/forms/1.0#template" 
      xmlns:fi="http://apache.org/cocoon/forms/1.0#instance"
      xmlns:jx="http://apache.org/cocoon/templates/jx/1.0">
  <jx:import uri="resource://org/apache/cocoon/forms/generation/template.jx"/>
  <title>Car selector</title>
  <para>This example illustrates how you can programmatically update the
    content of a selection list.</para>
  <para>
    This sample illustrates event-handling in Cocoon Forms and how selection lists can be changed
    programmatically.
  </para>
  <para>
    Event-handlers are defined in the form definition to update the selection lists and set
    the comment text below the table. This requires only a few lines of server-side JavaScript.
    Selection widgets also have a "submit-on-change" attribute set in the form template so that
    changes are considered immediately by the server.
  </para>
  <para>
    See "carselector_form.xml" and "carselector_template.xml" to see how this is done.
  </para>
  <content>
    <ft:form-template action="carselector" method="POST">
      <ft:continuation-id/>
      <table border="1">
        <tr>
          <td valign="top"><ft:widget-label id="make"/></td>
          <td valign="top">
            <ft:widget id="make">
              <fi:styling submit-on-change="true"/>
            </ft:widget>
          </td>
        </tr>
        <tr>
          <td valign="top"><ft:widget-label id="type"/></td>
          <td valign="top">
            <ft:widget id="type">
              <fi:styling submit-on-change="true"/>
            </ft:widget>
          </td>
        </tr>
        <tr>
          <td valign="top"><ft:widget-label id="model"/></td>
          <td valign="top">
            <ft:widget id="model">
              <fi:styling submit-on-change="true"/>
            </ft:widget>
          </td>
        </tr>
      </table>

      <br/>
      <ft:widget id="message"/>
      <br/>
      <br/>
      <input type="submit" value="Buy it!" onClick="document.forms[0].action='#{$cocoon/continuation/id}.continue';document.forms[0].submit()"/>
      <input type="submit" name="prev" value="Back" onClick="document.forms[0].action='#{$cocoon/continuation/previousBookmark/id}.continue';document.forms[0].submit()"/>

    </ft:form-template>
  </content>
</page>
