Displaying the form// show the form if not submitted yet
if ( !bSubmitted )
{
Out ( 'Here\'s a simple form.' );
|
So, on to displaying the form. In this case I want to display the form only when the form hasn't been submitted yet, but of course you could remove the "if" and display the form again every time - my search form does that. Note that as discussed earlier, bSubmitted will also be false if the form has been submitted with invalid data, so the form will refresh with the submitted values intact, ready for the user to fix the errors. Out ( '<form action="FormPage.asp" method="post">' );
|
The <form< tag has two main attributes - action and method. action defines which page to call when the form is submitted. You can hardcode your page name as I have, or you can make the form easier to maintain by using the name of the current page held in the ServerVariables collection, as shown below: Out ( '<form action="' + Request.ServerVariables ( 'SCRIPT_NAME' ) + '" method="post">' );
|
Note that the ServerVariables collection is quite "expensive" the first time you use it on a page - although it contains many useful values, please use sparingly. The method attribute can have two values, get and post. Only in very rare cases will you want to use get - since it uses the URL to submit the values it is limited to 255 characters of data, is very insecure, and ugly! post, on the other hand, passes the values in the HTTP headers where it cannot be seen, and the limit is much higher. Part 4: <form> inputs... |