Using HTML Forms |
Active Web |
One of the main features of any user interface is sending user data to the application. In an Active Web script application, the end user interface is the browser and the way of collecting user data is the HTML form.
A ‘form’ tag requires two attributes, the ‘action’ and the ‘method’. The action is the URL of the page that is to receive the form data. The method determines the way the form parameters are supplied to the script.
There are two methods, ‘post’ and ‘get’. The post method is preferred as it hides the data from the user and passes data to the script as a stream. The get method shows the data to the user and passes the data as a single string variable, which can have length limitations on certain platforms.
Between the start and end form tags there are ‘input’ tags, which are used to collect data from the user. The input tags define text boxes, drop down lists, check boxes and radio s. Each of these components has a name and when the submit is clicked the variables for each name are collected together and sent to the script in the ‘query string’.
If an input tag has no data then its parameter is not sent. If two or more input tags have the same name then the data will be seen as an array.
There is one more input tag, the hidden tag. This tag has a name and a value and is not seen by the user (hence hidden). The data from this tag is returned in the same way as other tags. It is used to set data values in a form that will be returned to the server.
The example below shows a form asking for a user name and password. Note that the password tag is of type password, which hides the text data from the user. Note also the hidden variable that is returned to the CGI program.
<form action=”verifyLogin.html” method=”post”>
User Name: <input type=text name=”username” size=30>
Password: <input type=password name=”password” size=30>
<input type=hidden name=”loginflag” value=”true”>
<input type=submit value=”Submit”>
</form>
Topic ID: 150112