Forms
HTML 3.2 - form, fields | HTML 4.0

Forms allow users to enter data which is then sent back to the server.
<form method="POST" action="/cgi-bin/programName" // Name of a program or ASP enctype="multipart/form-data" // Required for a file upload // Makes form parameters invisible onsubmit="return JavaScriptProcedure(this);" name="NameOfForm" target="response"> All the form tags must appear between the Form begin and Form end tags. </form> Input fields type = text | password | checkbox | file | hidden | submit | reset | image Radio Buttons Only one of several related options can be selected All buttons in a group must have the same name The key word CHECKED indicates the default value Displays only a round radio button without any text
M F <input type="radio" name="sex" VALUE="Male" CHECKED>M <input type="radio" name="sex" VALUE="Female">F
On Off <input type="radio" name="power" VALUE="On" checked>On <input type="radio" name="power" VALUE="Off">Off
Submit Button Send data to the server target (optional) names a window or frame
<input type="submit" name="submitButton" VALUE="Button Caption" target="response">
Reset Button Clears all the input fields to their default values
<input type="reset">
Text entry box Allows the user to type a single string Maxlength characters long
<input type="text" name="fieldName" value="Default Text" size="20" maxlength="20">
Select a file to send to the server This returns a file in the specified MIME format There is a Browse button This appears to be a major security hole
<input type="file" name="psfile" value="" accept="application/postscript">

Multiple rows of text
Warning: Netscape 4.05 and IE 4.72 implement this differently! With Netscape 4.05, in order to force the data to wrap, you must include wrap (one reference says wrap=virtual) which is not part of HTML 3.2 or HTML 4.
<textarea name=address rows=3 cols=20> Your comments here ... Wraps in IE 4.72, but not in Netscape 4.05 </textarea>
<textarea name=address rows=3 cols=20 wrap> This wraps in Netscape 4.05 and IE 4.72 </textarea>

Pick list Field with a down arrow which lets the users select an item from a list
<SELECT name="pageunit"> <OPTION SELECTED VALUE="pts">pts <OPTION VALUE="picas">picas <OPTION VALUE="in">in <OPTION VALUE="cm">cm </SELECT>


Example

Perl based (unix) Survey Form and a Results Form based on information from CGI Programming 101.

Use these links to view the perl scripts (actually, copies of them) and the data file.

xx.cgi.txt - Generates a 403 Forbidden error
xx_cgi.txt - Displays as a text file in Netscape 4.75
             but as an html page (ie, it is worthless) using IE 5.0.
             Just right click and select View Source to see the code.


Author: Robert Clemenzi - clemenzi@cpcug.org
URL: http:// cpcug.org / user / clemenzi / technical / HTML_Examples / Forms.htm