Creating Forms > Processing forms |
Forms are processed by the script or application specified in the action
attribute of the form
tag. Select a form and look in the Property inspector to see what the associated action is.
The simplest forms use JavaScript or VBScript to perform all form processing on the client side (as opposed to sending the form data to the server for processing). For example, you might have a small form at the bottom of a page that contains only two radio buttons labeled Yes and No, plus a Submit button. The form action might be a JavaScript function defined in the head
section of the document that displays one alert if the user selects Yes and another alert if the user selects No:
function processForm(){ if (document.forms[0].elements[0].checked){ alert('Yes'); }else{ alert('No'); } }
To use a client-side JavaScript function as the form action:
1 | Select a Submit button in a form. |
2 | Attach the Call JavaScript behavior to the button. (See Call JavaScript.) |
3 | In the JavaScript text box that appears while attaching the behavior, enter processForm() . |
4 | Add a processForm() JavaScript function (like the one shown above) to the head section of your document. |
You can handle many form-processing tasks using client-side scripting, but you can't save the data entered by the user or send it to someone else. For such purposes you need a server-side application such as a Common Gateway Interface (CGI) script. CGI scripts can be written in Perl, C, Java, or other programming languages. There are several sites on the Web that offer free CGI scripts that you can use (see HTML and Web technologies resources). You can modify those scripts to fit your needs. You can also ask your Internet service provider or Web team if there are any available CGI scripts that are already configured to run on your server.
For an introduction to CGI scripting, see The Common Gateway Interface.