advertisement
| AN EXAMPLE: GUESTBOOK OR COMMENTS FORM |
Followed everything? Don't worry. Lets put everything into practice and set up a straight forward comments form like the one below. This e-mails the info entered to a designated e-mail address. Feel free to add your comments by it!! Set up the form fields as before Make sure that each of your form field has a name that will make sense. We've used name, email, rating, helpful and other as our values. Each radio buttons and check boxes in the selectable questions should have the same group name value The bottom 2 buttons are standard submit and reset buttons Make sure you select the right button type for each. Just click over button and select the type as shown above (C). Now to the form Right click in the form and select form properties. You can name your form if you want. Now select settings (A) In the action box type in your email prefixed by mailto: (a). e.g. mailto:webmaster@fluffbucket.com Set Method to Post (b). And in the Encoding type box type text/plain (c) (we'll explain why in a minute. Adapt this form anyway you want to suite your site (think long and hard what email address to use. If in doubt set up a secondary one say at hotmail or yahoo) Save the page but don't publish it yet as there is something we'd like to add So far you've set up the form fields. Now you've added the form data. Essentially what the form does is that it sends the data from the form to the target defined in the action box (In this case your email address). We added the encoding type of text/plain because if you don't the data arrives in the form of an attachment (.att or .dat file). You'll need a program to open these (any text editor will do) and the data looks something like this Name=Alan+D&email=webmaster@fluffbucket.com&Rating= Cool&help=a+little&other+text=good+page&submit=submit Tad messy. By adding text/plain you get the info in the email text and in a readable form Name=Alan D email=webmaster@fluffbucket.com Rating=Good help=a little other text=good page submit=submit Now the form will work like that on its own, but some browsers will not warn their users that they have sent an email & they may repeatedly attempt to submit the same data. Because of this we'd recommend you add a warning The easiest way is to use an event handler to warn 'em. To do this rightclick over form. Select Form properties. Click on settings (A)
On the settings for Custom Form Handler click on extended (d) On the Extended attribute box click add (X). Then in name box add this (use exact case) onSubmit. Then in value box add this (again exact case. You can alter the message)
window.alert('this form is being sent by email even if nothing appears to be happening. Do not resubmit'); This is an event handler and we've a section on this and the language it uses called JavaScript We've stopped here for the moment but if you check our sections on Java and JavaScript to find out more about these skills. Or visit our links where there is a list of great CGI, Java & JavaScript resources resources and help. And also see our cool tips section where we teach you how to do some tricks with forms
This page © 2002 A.Duncan BWRS |