Is coding not your thing?

Watch Our
SohoLaunch Videos

See how EASY it is to:
Use the Quickstart Wizard
Create new pages
Open and edit pages
Add a category to a Shopping Cart
Add a product to a Shopping Cart

Click Here to Watch All 35 Tutorials!!

Get SohoLaunch
at HostPapa
and
SAVE!!

100% Green Energy Hosting from HostPapa.com


HTML Code Tutorial

Forms and Selection Boxes

Selection boxes add a little elegance to the structure of a form. They simply allow a user to make selections from a predefined list.

The Tags:

Select <select></select>

Attributes

  • name (required) supplies the name for the name/value pair.
  • size determines the number of options to be displayed at one time. Default=1.
  • multiple allows mutiple selections. (Control Key depressed)

Option <option></option>

Note: Closing option tag is not required.

Attributes

  • selected used to set default option.
  • value option text is default.

A simple form:

What states have you visited?

For multiple selections Hold Down the Control Key

The Form Code

<form method="post" action="script name">
What states have you visited?<br>
<select name="state[]" size="7" multiple>
<option> Alabama
<option>Arkansas
<option>Colorado
<option>Kentucky
<option>Tennessee
<option>Washington
<option>None of the above.
</select>
<input type="submit">
</form>

Note: Most people don't know how to make multiple selections using a selection box. Include the instruction for holding down the Control Key on your form.

PHP Script

<html>
<head><title></title></head>
<body>
<?
print "<h1>You have visted:</h1>";
foreach ($state as $value){
print "$value<br>";
}
print "<br>";
print "<a href=formselections.htm>Back to Tutorial</a>";
?>
</body>
</html>

Take a quiz. Take a Quiz on this Information.