Here's an example EWD page containing a form with an associated Action Script that will be invoked when the form is submitted. The Action Script is used to validate and process the submitted name/value pairs (eg file the data into the database).

  <ewd:config prePageScript="##class(ewd.examples).getMyData">
  <html>
    <head>
      <title>EWD Action Script Demo</title>
    </head>
    <body>
      <h4>Example Form with Action Script</h4>
      <form method="post" action="ewd">
        First Name: <input type="text" name="firstName" value="*" />
        Last name: <input type="text" name="lastName" value="*" />       
        City: <select name="city"></city>
        <input type="submit" name="submit" value="Save" action="##class(ewd.examples).setMyData" nextPage="mainMenu" />
      </form>
    </body>
  </html>

Note several features in this page:

The example below shows the structure of a typical Action Script, in this case using a Caché Class Method. An Action script has a single input parameter (sessid) and returns a null value if no validation errors occurred. If a validation error occurs, the Action Script method should Quit with the associated error message as the ReturnValue and EWD will automatically display this in a Javascript Alert window and re-display the form (with the previously entered values automatically redisplayed within the form).

The variable sessid uniquely identifies the user's session and is passed to your Action script automatically by EWD at run-time. Most of EWD's API methods require the sessid to be passed into them, as shown in the example which gets the session variables that were automatically created by EWD when the form was submitted:

ClassMethod setMyData(sessid As %String) As %String
{
 s firstName=$$getSessionValue^%zewdAPI("firstName",sessid)
 i firstName="" QUIT "You must enter a first name"
 s lastName=$$getSessionValue^%zewdAPI("lastName",sessid)
 i lastName="" QUIT "You must enter a last name"
 s city=$$getSessionValue^%zewdAPI("city",sessid)
 d ##class(ewd.examples).saveData(firstName,lastName,city)
 QUIT ""
}

Click the Enterprise Web Developer/Examples tab for more detailed examples of the use of forms in EWD