The Text Area
|
Introduction
|
A text area is a large control that is a substitute to handle large
paragraph where the text box cannot or should not be used.
To create a text area, use the <TextArea> tag which must also
be closed. Here is an example:
|
Characteristics of the Text Area
|
The dimensions of a text area are the main properties that set it apart
from the text box control. The width of a text area is set using the COLS
attribute of the <textarea> tag. Therefore, to increase the width of
the text area, assign the desired numeric value to the cols
attribute. The width is measured by the number of characters that can
be displayed on one line of text. By default, a width of a text area is
set to 20 characters. To change this, you can assign a higher value to the
attribute:
The height of a text area is measured by the number of
visible lines of text that the text area can display. By default, the text
area is configured to display two lines of text. This property is
controlled by the ROWS attribute. To change or increase this
number, assign an appropriate numeric value to the rows attribute. You can
specify either one of the COLS or the ROWS values. You can also specify both to
control the dimensions of the text area. When using both attributes, there
is no order of the attributes. Here is an example:
If you are planning to access the text area from your
code, you should give the control a name.
|
Password Text Boxes
|
Creating a Password Text Box
|
HTML provides a specific text designed for a form's password. This looks
like a classic text box and is created the same. The main difference is
that the text that the user types doesn't display the characters that are
being entered. As the user types in the password text box, text appears as
a series of asterisks or periods.
Like the regular text box and many other controls, to create a password text box, use the <input> tag and specify the control type as password assigned to the type attribute.
Here is an example:
<input type="password">
|
Characteristics of the Password Text Box
|
The size of the password text box is controlled by the size
attribute of the <input> tag. To increase the width of the control, assign
the desired numeric value to the size attribute. Here is an example that
creates a text box control:
<input type="password" size="25">
The text that is typed in the password text box is held by
the value
attribute. You can use this attribute to find out what password the user
typed.
If you plan to retrieve the password value in a script or code of
any kind, give the control a name. This is done by assigning a name string
to the name attribute. Here is an example:
<input type="password" name="Guarded">
|
Check Boxes
|
Creating a Check Box
|
A check box is a small square box that allows the user to select an item
or to deselect it. The user makes this decision by clicking in the small
square box. By default, or depending on how the control is configured, the
square box is white and empty. This indicates that it is false or off.
When the user clicks it, a small check mark appears in the square box,
indicating that it is true or on.
To create a check box, use the <input> tag and specify the
control type as checkbox, CheckBox, or CHECKBOX. Here is an example:
|
|
A check box doesn't display what it is used for. Therefore, you should (always) add a label close to it to help the user
know the role of this control.
If using many check boxes in a group, the user is able
to click or select as many different check boxes that the application
designer allowed.
|
Characteristics of a Check Box
|
As described already, when the user clicks the check box, its value becomes
on or true. You can programmatically set this state by using the checked
attribute of this tag. If you assign it a true value, the check box
becomes checked. Otherwise, it would be unchecked. Here is an example of
using the tag:
<input type="checkbox" checked="true">
If you plan to use a check box in a script, you should
give it a name. This is done by assigning a string to the Name
attribute.
|
Check Box Events
|
The most popular and probably the most important event of a check box
fires when the user clicks the check box, selecting or deselecting it.
Therefore, you can use the onClick event of the check box to find out
whether the control has been selected or not; if so, you can decide what
to do in response.
|
Radio Buttons
|
Introduction
|
A radio button is a small round and white circle that allows the user to
select an item from a group. This is because a radio button is generally
accompanied by others. From a group of items, represented each by a
circle, when the user clicks one of them, none of the others is
selected. To change the selection, the user must click another choice in
the group.
To create a radio button, use the <input> tag and specify the
type
attribute as radio. Here is an example:
To make your radio buttons effective, you should
always provide at least two radio buttons in a group.
|
Characteristics of Radio Buttons
|
One of the most important attributes to set on the radio button is the
name. This attribute should be used even if you don't plane to use the
radio button in a script, since many radio buttons can use the same name,
this name will be helpful in determining what particular control has been
selected. Therefore, the same value (string) for the Name attribute
can be assigned to each radio button of the same group.
The checked attribute, as applied to the check
box, can be used in two circumstances, if you want one of the buttons in
the group to be selected by default, assign a true value to its checked
attribute. Here is an example:
You can also use the checked attribute in your script
to find out what radio button was clicked at one time.
|
Radio Button Events
|
Because it is first of all a button, the most fundamental event that a
radio button can send to the browser is called onClick. This event fires when
the user clicks or select a particular radio button. You can therefore use
it to take action as a response.
|
Combo Boxes
|
Introduction
|
Like a group of radio buttons, a combo box allows the user to select an
item from a group, namely a list. A combo box has the shape as a text box,
except that it is equipped with an arrow on the right side of the control.
This arrow control allows the user to display a list of items that are
hidden by the text side of the combo box. When the list displays, the user
select one item from the list. Once the item has been selected, the list
retracts back to its original text-like size.
To create a combo box, use a tag called select. This tag has to be closed.
After typing the <select> tag, create each item that is part of the
control using the <option> tag. Each item uses its own
<option> tag. After listing the items, make sure you close the select tag as
</select>.
Here is an example:
|
|
- Start a new file in your text editor and type the following:
<h1>Georgetown Cleaning Services</h1> <form name="frmCleaningOrder"> <table border="0" width="540"> <tr> <td width="446" colspan="4"> <h3>Order Identification</h3> </td> </tr> <tr> <td width="106">Customer Name:</td> <td width="150"><input type="text" name="txtCustomerName" size="20"></td> <td width="108">Customer Phone:</td> <td width="150"><input type="text" name="txtCustomerPhone" size="20"></td> </tr> <tr> <td width="106">Date Left:</td> <td width="150"><input type="text" name="txtDateLeft" size="20"></td> <td width="108">Time Left:</td> <td width="150"><input type="text" name="txtTimeLeft" size="20"></td> </tr> <tr> <td width="106">Date Expected:</td> <td width="150"><input type="text" name="txtDateExpected" size="20"></td> <td width="108">Time Expected:</td> <td width="150"><input type="text" name="txtTimeExpected" size="20"></td> </tr> </table> <hr> <table border="0" width="596"> <tr> <td width="381"> <table border="0" width="381"> <tr> <td width="128"><b>Item Type</b></td> <td width="71"><b>Unit Price</b></td> <td width="38"><b>Qty</b></td> <td width="46"></td> <td width="66"><b>Sub-Total</b></td> </tr> <tr> <td width="128">Shirts</td> <td width="71"><input type="text" name="txtShirtUnitPrice" size="7" value="0.95"></td> <td width="38"><input type="text" name="txtShirtQuantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnShirts"></td> <td width="66"><input type="text" name="txtShirtSubTotal" size="8" value="0.00"></td> </tr> <tr> <td width="128">Pants</td> <td width="71"><input type="text" name="txtPantsUnitPrice" size="7" value="2.75"></td> <td width="38"><input type="text" name="txtPantsQuantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnPants"></td> <td width="66"><input type="text" name="txtPantsSubTotal" size="8" value="0.00"></td> </tr> <tr> <td width="128"><select size="1" name="cboItem1"> <option selected>None</option> <option>Women Suit</option> <option>Dress</option> <option>Regular Skirt</option> <option>Skirt With Hook</option> <option>Men's Suit 2Pc</option> <option>Men's Suit 3Pc</option> <option>Sweaters</option> <option>Silk Shirt</option> <option>Tie</option> <option>Coat</option> <option>Jacket</option> <option>Swede</option> </select></td> <td width="71"><input type="text" name="txtItem1UnitPrice" size="7" value="0.00"></td> <td width="38"><input type="text" name="txtItem1Quantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnItem1"></td> <td width="66"><input type="text" name="txtItem1SubTotal" size="8" value="0.00"></td> </tr> <tr> <td width="128"><select size="1" name="cboItem2"> <option selected>None</option> <option>Women Suit</option> <option>Dress</option> <option>Regular Skirt</option> <option>Skirt With Hook</option> <option>Men's Suit 2Pc</option> <option>Men's Suit 3Pc</option> <option>Sweaters</option> <option>Silk Shirt</option> <option>Tie</option> <option>Coat</option> <option>Jacket</option> <option>Swede</option> </select></td> <td width="71"><input type="text" name="txtItem2UnitPrice" size="7" value="0.00"></td> <td width="38"><input type="text" name="txtItem2Quantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnItem2"></td> <td width="66"><input type="text" name="txtItem2SubTotal" size="8" value="0.00"></td> </tr> <tr> <td width="128"><select size="1" name="cboItem3"> <option selected>None</option> <option>Women Suit</option> <option>Dress</option> <option>Regular Skirt</option> <option>Skirt With Hook</option> <option>Men's Suit 2Pc</option> <option>Men's Suit 3Pc</option> <option>Sweaters</option> <option>Silk Shirt</option> <option>Tie</option> <option>Coat</option> <option>Jacket</option> <option>Swede</option> </select></td> <td width="71"><input type="text" name="txtItem3UnitPrice" size="7" value="0.00"></td> <td width="38"><input type="text" name="txtItem3Quantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnItem3"></td> <td width="66"><input type="text" name="txtItem3SubTotal" size="8" value="0.00"></td> </tr> <tr> <td width="128"><select size="1" name="cboItem4"> <option selected>None</option> <option>Women Suit</option> <option>Dress</option> <option>Regular Skirt</option> <option>Skirt With Hook</option> <option>Men's Suit 2Pc</option> <option>Men's Suit 3Pc</option> <option>Sweaters</option> <option>Silk Shirt</option> <option>Tie</option> <option>Coat</option> <option>Jacket</option> <option>Swede</option> </select></td> <td width="71"><input type="text" name="txtItem4UnitPrice" size="7" value="0.00"></td> <td width="38"><input type="text" name="txtItem4Quantity" size="4" value="0"></td> <td width="46"><input type="button" value="Calc" name="btnItem4"></td> <td width="66"><input type="text" name="txtItem4SubTotal" size="8" value="0.00"></td> </tr> </table> </td> <td width="201"> <table border="0" width="100%"> <tr> <td width="100%" align="center" colspan="2"><input type="button" value="Calculate Order" name="btnCalculate"></td> </tr> <tr> <td width="50%">Cleaning Total:</td> <td width="50%"><input type="text" name="txtCleaningTotal" size="8" value="0.00"></td> </tr> <tr> <td width="50%">Tax Rate</td> <td width="50%"><input type="text" name="txtTaxRate" size="6" value="5.75">%</td> </tr> <tr> <td width="50%">Tax Amount:</td> <td width="50%"><input type="text" name="txtTaxAmount" size="8" value="0.00"></td> </tr> <tr> <td width="50%">Order Total:</td> <td width="50%"><input type="text" name="txtOrderTotal" size="8" value="0.00"></td> </tr> </table> </td> </tr> </table> <hr> <p><input type="reset" value="Start New Cleaning Order" name="btnNewOrder"></p> </form>
- Save the file as cleaningorder.htm in your JavaScript Lessons folder
- Preview it in your browser
- Return to your text editor
Characteristics of a Combo Box
|
To select a default item from the combo box, use the selected
attribute of the <options> tag. Here is an example:
|
Events of a Combo Box
|
Besides looking at a combo box to see its current
value, the most expected action the user can make on a combo box is to
click its arrow and select a new item. There are two main ways to select a
value in a combo box. The user can first press Tab a few times until the
combo box receives focus. An alternative is to click the down pointing
arrow. In both cases, when the combo box receives focus, it fires an onFocus
event.
If the user pressed Tab to give focus to the combo
box, he or she can press Alt + the down arrow key to display the list of
the control. Remember that the user can also click the arrow to display
the list. To actually select an item from the list, the user can click it.
When this is done, the combo box fires an onChange event to
indicate that its value has changed.
After using a combo box, the user can press Tab or
click another control. In both cases, the combo box would fire an onBlur
event to indicate that it has lost focus.
|
List Boxes
|
Creating a List Box
|
Like radio buttons or a combo box, a list box displays a list of items
that the user can select from. Unlike a combo box, a list box displays a
taller list and can even display all of its items all the time.
Like a combo box, a list box is created using the <select> tag. Like
the combo box, each item of a list box is created using the <option>
tag. To make the control a list box, the <select> tag is equipped with an
attribute called size. This attribute accomplishes two purposes: it makes
the control become a list box and it sets the vertical size of the list
box. In other words, it decides on the number of items the list box can display at
a time.
Here is an example:
|
Characteristics of a List Box
|
A list box can be configured to allow the user to select one item. To
select an item from the list, set the selected attribute of its
<option> tag to true.
Here is an example:
Unlike a combo box, a list box can be configured to allow
the user to select more than one item from the list. To allow this,
include the multiple attribute in the <select> tag. Here is an example:
|
List Box Events
|
The most commonly used and the most important event of a list is called
onChange. This event fires whenever the user makes a selection in the list
box. This allows you to take appropriate actions.
No comments:
Post a Comment