Forms (Operation)/CGI

Now that you have the basic idea on how to create a form, you need to know how to make it work. Allowing the user to type something into a text box is only part of the job. The user requires a way to submit or reset the information. This is what buttons are for. For a submit button, you would type the tag <INPUT TYPE=SUBMIT VALUE="Submit">. Within this tag, you could add the JavaScript commands to perform operations that need to be accessed. You can also create buttons to perform scripted operations by typing <INPUT TYPE=BUTTON VALUE="Click to operate script">. For a reset button, you would type <INPUT TYPE=RESET VALUE="Reset">.

You may remember back in Lesson Six - Making Links we created an image map. You can do a similar thing here by creating an image field. You create it by typing <INPUT TYPE=IMAGE SRC="USEMAP.gif" NAME=USA VALUE="STATE">. Here, the user can click on a map of the U.S., and, depending on where they click, they can be guided to a certain report. For instance, if the mouse happens to click on the coordinates (15,30), the server will receive the field name (USA) with an x coordinate (15) and the field value (STATE) with a y coordinate (30). The report may generate something for that state clicked or it may generate a report for a certian region.

These are the items that make your form active. However, it is never truly active until you have a script to launch it. One way to do this is through a CGI (Common Gateway Interface). You can create your own CGI using a language like C++ or Perl, or you can find a premade CGI to operate your form. You would insert your CGI after the NAME="" portion of the <FORM> tag by typing ACTION="www.my-web-site.com/cgi-bin/cgi-program" METHOD="post". You can find CGI scripts as well as learn how to create them at CGI Resource Index.

For an easier approach, you can have people submit the form information to your e-mail. To do this, in the ACTION portion of the form, instead, you would type ACTION="mailto:myemail@address.com". To see a working version of this form, click here. See it as a business site. See another business site. There are some down sides to using this. If the users computer mail program is not configured to remain closed during these forms, they may get a pop-up of their mail program that will allow them to further edit the information they will be sending.

If you want to personalize your form, one way may be to be able to choose what your button looks like. To do this, you'd enter the code below:

<BUTTON NAME="Back" TYPE=BUTTON>
  <IMG SRC="back_button.gif" VSPACE=5>
  <B>Click to return to our <FONT COLOR=RED>Home Page</FONT></B>
</BUTTON>


Question: That's it? That's all I need to know about forms? Cool. But how do I make several pages load at the same time on my screen?

Answer: You have actually been learning about forms through this whole tutorial. Now, to advance your skills, let's learn about frames.

Previous | Home | Next

If you have a question about any of the lessons, feel free to ask.

1