Forms

Introduction

Forms allows users of your web pages to enter information, and then when the form is "submitted", the information can be passed back to your web server to be processed and stored.

Creating a simple form

You can create a form inside either the body, a div or other elements such as a table. To create a simple form inside a div, you can create a div in the usual manner, such as using Quick Div from the Containers menu, and then select it.

Then you can choose Quick Form from the Forms menu.

Modifying the form

When you have a form inside a div, you can then modify it to work with your own server applications. The easiest way to select your new form is in the Navigator and by expanding the tree of elements, you'll be able to see your new form and select it.



Forms can have many attributes, but the important ones are:

method - This controls what method to use to pass the data back to your server, GET is the simplest method, but is limited to the amount of data you can pass, whereas POST can sometimes be a little more complicated, but you can pass back large amounts of data, even hundreds of megabytes.

name - This is a critical attribute if you want to control your form with JavaScript, as it allows it to be accessed easily using the JavaScript DOM tree.

action - This is the script on your web server that the data will be passed to, if it's not stated, then the current page will be used, alternatively you can state something like /cgi-bin/submit-address.php for the target.

Adding elements to the form

When you have the form selected, you can add elements to the form, these can be any XHTML/HTML element but mostly they will be input elements like text entry fields, checkboxes and buttons.



You can add as many elements as you like to a form, and then you should give all elements name attributes as this is what will be passed back to your server.