|
|
Forms in HTMLIts pretty easy explaining how to put forms on your pages; telling you how to get them to result in an e-mail is a little more difficult. First of all, many Internet service providers have special software (cgi-script) for performing the form-to-mail procedure. These will require a slightly different method to that described here, so check with your ISP first. The method described here uses the mailto: action to interpret the form. It is the simplest method, and produces only crude results (but they do the job!). It must be noted that
mailto: only works with Netscape browsers and you should tell your readers such. The most effective use of forms is always through the use of cgi-script.
|
getting started
|
dialog items
|
buttons
|
text entry
|
drop-downs
|
example
|
mailto
|
<form>
<form action="mailto:username@provider.com"
method="POST" target="resultswindow">
<input type="hidden" name="subject"
value="Title of Form">
form dialogs in here
<input type="submit">
<input type="reset">
</form>
The value of the action attribute
contains the address that you wish the results of the form to be sent to, ie. swap
username@provider.com with your own e-mail address. If you are using a special
form-to-mail processing script from your access provider, the action attribute
should be changed to the address of the processing script. If you are using form-to-mail
script, the target attribute can be used to specify a frame or window to
direct the results to.
Specifying an input type as
hidden effectively enables you to create variables that the user
does not see. These variables are then returned in the reply e-mail or used by the processing
script. They are handy if you have more than one form - use them to give the form a title so
you know which one the reply e-mail resulted from.
Input types submit and reset are required to give buttons which
enable the user to send or clear the form.
The dialog items (text boxes, drop-down lists, etc.) available for forms are described below.
Dialog items are placed using the <input> command and specified
using the type attribute.
The following types are available: text, radio, checkbox, password, image and file.
type=text<textarea>
for multiple line text boxes.
name=textsize=numbermaxlength=numbersize attribute, then the field
will scroll.
value=text![]()
Just one line of text please:
<INPUT type=text name="Single-Line Text Box" size=50 maxlength=75 value="default
text">
![]()
type=radioname. A single radio button can be shown, provided it has a unique
name.
name=textvalue=textchecked![]()
<INPUT type=radio name="Radio Button Group example" value="yes" checked>
yup
<INPUT type=radio name="Radio Button Group example" value="no"> nope
![]()
type=checkboxname. A single checkbox can be shown, provided its name is
unique.
name=textvalue=textchecked![]()
<INPUT type=checkbox name="CheckBox Button Group example" value="1"> one
<INPUT type=checkbox name="CheckBox Button Group example" value="2"> two
<INPUT type=checkbox name="CheckBox Button Group example" value="3"
checked> three
![]()
type=passwordname=textsize=numbervalue=text![]()
Please give the password:
<INPUT type=password name="Password Text Box" size=50>
![]()
type=imagename attribute.
name=textsrc=URL<img> tag.
align=left|right|middle|top|texttop|
absmiddle|baseline|bottom|absbottom<img> tag.
border=pixels<img> tag.
height=pixels, width=pixels<img> tag.
hspace=pixels, vspace=pixels<img> tag.
![]()
Submit a colour:
<INPUT type=image name="ColoursImageField" src="graphics/colours.jpg"
align="absmiddle">
![]()
type=filename=textsize=nmaxlength=naccept=MIME content type![]()
Send your file:
<INPUT type=file name="The users file" size=35 accept="image/*" maxlength=50>
![]()
type=submit type=resetvalue=text![]()
<INPUT type=submit value="Yes! I want a copy">
<INPUT type=reset value="Clear all data">
![]()
<textarea></textarea>name=textcols=numberrows=numberwrap=off | soft | hardwrap=off means no wrapping will occur - text is sent exactly as
typed. Setting wrap=soft means the display wraps but the text is
sent as typed. Setting wrap=hard means the display wraps and
text is sent with line breaks at all wrap points. Note: The values soft and
hard have now replaced virtual and
physical as text wrapping attributes.
![]()
Please write lots of text:<br>
<textarea name="Multi-Line Text Box" cols=50 rows=10 wrap=physical>default
text</textarea>
![]()
<select> <option><option> element with the
<select> tags for each of the items in your list. You may have seen list
boxes used as hyperlinks to other locations. This is JavaScript at work and unfortunately is beyond the scope of this Guide.
name=textsize=numbermultiplevalue<option> element. This specifies what is returned in the
e-mail for a selected item. The text between the opening and closing
option tags is what appears in the list box.
selected<option> element to specify a default selection.
![]()
Pick one:
<SELECT name="Single-line ListBox example">
<OPTION value="1">choice 1</OPTION>
<OPTION selected value="2">choice 2</OPTION>
<OPTION value="3">choice 3</OPTION>
<OPTION value="4">choice 4</OPTION>
</SELECT>
Pick some:
<SELECT name="Multi-line, multi-selection Listbox example" size=3 multiple>
<OPTION value="1">choice 1</OPTION>
<OPTION selected value="2">choice 2</OPTION>
<OPTION value="3">choice 3</OPTION>
<OPTION value="4">choice 4</OPTION>
</SELECT>
![]()
Example Form
<h2>Example Reply Form</h2>
<form action="mailto:user@provider.com" method="POST">
<input type="hidden" name="subject" value="Example Form">
<select name="age">
<option value="under 18">under 18 </option>
<option selected value="18 to 25">18 to 25 </option>
<option value="25 to 30">25 to 30 </option>
<option value="30 to 40">30 to 40 </option>
<option value="over 40">over 40 </option>
</select> Your age<br>
<input type=text name="name" size=40> Your name<br>
<input type=text name="email" size=40> Your e-mail
<p>
<textarea name="details" cols=50 rows=10 wrap=physical>Something about
yourself</textarea>
<p>
I think this guide is
<input type=radio name="opinion" value="great" checked> great
<input type=radio name="opinion" value="middling"> middling
<input type=radio name="opinion" value="very poor"> very poor
<p>
<input type="submit" value="Process Data">
<input type="reset" value="Clear Data">
</form>
![]()
When the mailto action is used, as above, the results of the form are
returned in a contiguous stream. This means the resulting e-mail from the
above example form would look something like:
There is software available, such as that from Nisseb for the Mac and Informatik for the PC, which will parse the returned e-mails and present them in a more useable way. As stated above, it must be noted that
subject=Example+Form&age=under+18&name=Richard+Rutter
&email=rrutter@woodhill.co.uk&details=This+is+a+test
+and+only+a+test.&opinion=great
mailto: only works with Netscape browsers and MS Internet Explorer 3 beta 2 or later; the most effective use of forms is always through the use of cgi-script. Any Internet Service Provider worth paying money to will have form-handling script available.
|
Sizzling HTML Jalfrezi | |
| ©1997 Richard Rutter | ![]() | |
| rrutter@woodhill.co.uk | ||