![]() |
Text-Based Controls |
|
||||||||||||||||||||
|
Text Box Properties |
|
By default, the text box control provides enough space to display a first name, a username, or a short e-mail address. If it is not enough, you can widen the text box. To increase the width of a text box, the <input> tag is equipped with an attribute called Size. Therefore, to widen a text control, assign an appropriate numeric value to the Size attribute. Like all HTML attributable tags (such as <body> or <font>), there is no rule on the order of attributes. Here is an example that creates a text box control: <input type=text size=40> The text that displays in a text box is held by an attribute called Value. To display text in the text box, assign a string to the Value attribute. Here is an example: <input type="text" value="James Fame Ndongo"> When writing code, we will find out that, to retrieve the content of a text box, you can use the Value attribute. If you plan to use a text box 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="text" name="FirstName"> To refer to a text box control from a script, type the document keyword, followed by a period, followed by the name of the form that hosts the control, followed by a period, followed by the name of the text box control. Suppose you create a form named CreditApplication that hosts a text box called txtFirstName. Here is how you can access the txtFirstName control of the CreditApplication form: document.CreditApplication.txtFirstName This would then allow you to access a property of the text box using the period operator. For example, to access the content of a text box, call the Value property. Here is an example: document.CreditApplication.txtFirstName.value
|
|
Text Box Events |
|
There are many events associated with a text box control. When the user clicks inside of the text box, an event called OnClick is sent to the browser. When the user starts typing and as long as the user is typing in the text box, an event called OnKeyDown is sent to the browser. When the text in the text box changes, such as while the user is typing, the OnChange event is sent. You can use any of these events to take appropriate actions. |
|
Practical Learning: Using Text Boxes |
|
|
Text-Based Controls: A Text Area |
|
|
|
Creating a TextArea Control |
|
|
|
TextArea Properties |
|
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. |
|
Practical Learning: Using a Text Area Control |
|
|
Text-Based Controls: Password Text Boxes |
|
|
|
Creating a Password Text Box |
|
Here is an example: <input type="password">
|
|
Password Text Box Properties |
|
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">
|
|
|
||
| Previous | Copyright © 2002-2007 FunctionX, Inc. | Next |
|
|
||