Creating User Fill-In Forms |
|
![]() ![]() ![]() ![]() |
Now it's time for a little
interaction with the outside world! Get your viewers involved in your site and ask for
some feedback, have them sign a guest book or even get them to order stuff from you. The
possibilities are endless. Just how endless depends a little on the services you can access from your web hosting system. If you have access to a cgi-bin directory and are allowed to set up scripts and build databases then you can really have a blast. Otherwise, you'll have to settle for forms that end up e-mailing data to you which you have to process manually. Either way, the forms are still the same. Defining a FormIt's simply a matter of enclosing some field definitions - input, select and textarea - between the <form></form> tags. Ah, if it were only that simple. Let's start out by looking at the code for my guest book form (I'll leave out all the extraneous stuff and just show you the actual FORM definition): <form method="POST" enctype="text/plain" action="mailto:mrusk@radix.net"> Your name please:<br> <input type=text name=name size=50 maxlength=50><br> How did you find me?:<br> <select name=howfound> <option selected value="Best Friend">Best Friend </option> <option value="Close Friend">Close Friend </option> <option value="Friend">Friend </option> <option value="Larry King">Larry King </option> <option value="Grease Man">Grease Man </option> <option value="Told Not to Come">I was told not to visit </option> </select><br> Comments?:<br> <textarea name=comment wrap=virtual rows=5 cols=55>I love this site because...</textarea> <br> <input type=submit value=Submit> <input type=reset value=Clear> </form> There are a number of things to point out. The first, I've left this form defined as a "mailto" action, even though Microsoft Internet Explorer doesn't deal with it very well. In actual practice, my ISP has provided a basic script that allows me to duplicate this action without invoking "mailto". I've converted the form to use that script by changing the action attribute to point to the URL they gave me. The second, if you look closely at the code, you'll notice that I put in a bit of text as a label for a field, followed by a <br> then the actual field. Being a little anal retentive, I tend to like things lined up on a margin. This makes the left side of my form be straight. I can't stand to see forms that have fields all over the place. Simply drives me nuts! Lastly, you'll notice the enctype attribute set to "text/plain". When I first built the form I was copying someone else's example (view source is one of the best teachers). I was getting my data back in one long line with all kinds of % stuff in between the fields. I had even gone to the trouble of downloading a program that would take the string and format it for me. Then I stumbled across the "text/plain" definition when I was looking at headers on e-mail messages and gave it a shot. Sure enough, it worked great! One field per line with the name in front of it. Couldn't ask for more! Text, Text Areas, Check Boxes, Radio Buttons and Drop Down MenusYou have your choice of three basic field types: input for single line or button entry; select for getting one or more values from a list of choices; and textarea for gathering a block of text. For your amusement, I've included some examples for you to play with so you can see what the different values do to the viewer.
I hope you've experimented around with the different field types. All the details are included with my descriptions of input, select and textarea. You can check them out in detail when you're ready to build your own forms. Now let's scoot along and see how to do an image map! |
![]() ![]() ![]() ![]() |
Comments to author: mrusk@radix.net All contents copyright © 1996-1997, Michael T. Rusk |