<form> Tagaction attributeaction
attribute is the empty string ("").mailto:" only if all else fails.
text/plain is used
(see enctype attribute
below for information on encoding type).cgi/bin (stands for Common Gateway
Interface-binaries).method attributemethod attribute sets the method by which the browser
sends the form's data to the server.post and get.post
action
attribute contacted.CONTENT_LENGTH.get
method attribute (i.e., if
the method attribute is omitted, get
will be used).QUERY_STRING.get for small forms with a few short lines or if you
are inexperienced at writing server-side form applications.get to be able to pass parameters
to the application from outside of the form.
Since get obtains parameters from the
action URL, any parameter-value pairs may be passed.<a>
tag, replace the ampersand by its character entity equivalent.enctype attributemultipart/form-data,
text/plain.application/x-www-form-urlencoded
%0D%0A.multipart/form-data
method attribute set to
post.text/plain
mailto:" in the URL
in the action attribute.
<form action="">
<p>
<b>Name</b>:
<input type="text" name="myname" size="25"/><br/><br/>
<input type="submit" value="Submit my name"/>
</p>
</form>
<h2>Google</h2>
<form action="http://www.google.com/search" method="get">
<p>
<!-- h1=en English -->
<input type="hidden" name="hl" value="en"/>
<input type="text" name="q" size="25"/>
<input type="submit" value="Google Search"/>
</p>
</form>
Google Search,
the URL will be http://www.google.com/search?hl=en&q=Charles.
When you type in "Charles Li" and press Google Search,
the URL will be http://www.google.com/search?hl=en&q=Charles+Li.
<input />Tagtype and name attributes required.type: type of control (e.g., text, button, radio, etc.).name (of field): used during the form-submission process to
the server.Four types: conventional, masked for security, a field that names a file to be transmitted, and a multi-line text field.
type is
text.
size attribute) and the maximum number of
characters to accept from the user (via the maxlength
attribute).maxlength>size: text scrolls back
and forth in text entry box.maxlength<size: extra blank space in
text entry box.size browser dependent.maxlength unlimited.value attribute to specify an initial default
value for the field.Student ID: <input type="text" name="student_id" size="9"
maxlength="9" /><br />Major: <input type="text" name="major" size="20"
maxlength="32" value="math" />type attribute is password.
Please enter your credit card number:<br />
<input type="password" name="credit_no" size="16"
maxlength="16" />enctype
of the form set to
"multipart/form-data" and
method
attribute set to post.type attribute set to checkbox.name, value attributes required.checked attribute to display a default checked box and
include the value when submitting the form, unless the user unchecks
the box.<form action="parseform.cgi" method="get">
<p>
What class(es) are you taking?
</p>
<p>
<input type="checkbox" name="class" value="p20A" />PIC 20A
<br />
<input type="checkbox" name="class" value="p10B" />PIC 10B
<br />
<input type="checkbox" name="class" value="p40A"
checked="checked" />
PIC 40A
</p>
</form>type attribute set to radio.name, value attributes required.checked attribute.<form action="parseform.cgi" method="get">
<p>
What is your favorite color?
</p>
<p>
<input type="radio" name="color" value="red" />Red<br />
<input type="radio" checked="checked" name="color" value="blue" />Blue
<br />
<input type="radio" name="color" value="green" />Green
<br />
<input type="radio" name="color" value="yellow" />Yellow
</p>
</form>value to distinguish
among them.value attribute,
so they must all have different names.type is submit.name, value attributes optional.value attribute appears, the button
labeled with that value.name and value attributes given, the
value labels the button and the value and name are added
to the parameter list sent to the server.type is reset.value attribute to display alternate
label.type is image.src attribute required (value is the URL of
the image file).name attribute.alt attribute optional (but recommended) tells
the browser what to display if the image is not supported.type attribute set to hidden.name, value attributes required.<textarea> Tagname attribute required.%0D%0A and sends them to server
using the name specified by the name attribute.<textarea> and </textarea>
tags.rows, cols attributes
<textarea name="comments" rows="8" cols="50">
Please write your comments here.
</textarea>
appears as:
<select> tag<option> tag gives list of items inside
<select> and </select>
tags, creates a menu of choices.name attribute required and used by browser when
submitting the choice(s) to the server.name when
the form data submitted to the server
This might appear as ...?...name=value1, value2,....multiple attribute
multiplesize attribute
size is 1, if multiple is not specified,
choices shown as a pull-down menu.size > 1 or
multiple specified,
choices displayed in scrolling list.<option> tagvalue attribute
<option> tag.selected attribute included to preselect one
or more options, which the user may deselect; value is
selected.label attribute if set, its value is used to
label the option, not the contents of the
<option> tag.
<p>
Choose your vegetable (one)
</p>
appears as:
<p>
<select name="veggie">
<option>carrots</option>
<option>broccoli</option>
<option>squash</option>
<option>spinach</option>
</select>
</p>
Choose your vegetable (one)
<select name="veggie" size="2">
<option>carrots</option>
<option>broccoli</option>
<option>squash</option>
<option>spinach</option>
</select>