Using HTML Quickform for Form Processing - Text, Password, Textarea
(Page 4 of 13 )
The text element produces the single-line text-entry box displayed by the HTML tag <input type="text">.
These are the valid arguments when creating a text element:
- $elementName: The name attribute of the element’s <input> tag
- $elementLabel: The label of the element in the form
- $attributes: Arbitrary element attributes, as a string or an associative array These are its methods:
- setSize(): The size attribute controls the width of the displayed text box.
- setMaxlength(): The maxlength attribute tells the browser how many characters can be typed into the text box.
The following is a sample usage:
$form->addElement('text','first_name','First Name:','class="big"');
This is the sample HTML:
<tr>
<td align="right" valign="top"><b>First Name:</b></td>
<td valign="top" align="left"><input class="big" name="first_name" type="text"
/></td>
</tr>
password
The password element behaves just like the text element, but it is displayed with the <input type="password"> tag instead of <input type="text">. This means that text entered into a password box isn’t displayed as it’s entered. Instead, an asterisk or other symbol is shown in place of each character.
textarea
The textarea element produces the multiple-line text-entry area displayed by the HTML tags <textarea></textarea>.
These are the valid arguments when creating a textarea element:
- $elementName: The name attribute of the element’s <input> tag
- $elementLabel: The label of the element in the form
- $attributes: Arbitrary element attributes, as a string or an associative array
The following are its methods:
- setWrap(): The wrap attribute controls how lines are wrapped inside the textarea. soft means that the browser displays wrapped text but doesn’t send the line breaks with submitted data, hard means that wrapped text is displayed and sent to the server, and off means the browser does no wrapping on its own.
- setRows(): The rows attribute controls how many lines of text are visible in the textarea at one time.
- setCols(): The cols attribute controls the width of the textarea.
The following is a sample usage:
$form->addElement('textarea','profile','Describe yourself:','wrap="soft"');
The following is the sample HTML:
<tr>
<td align="right" valign="top"><b>Describe yourself:</b></td>
<td valign="top" align="left"><textarea wrap="soft" name="profile">
</textarea></td>
</tr>
This chapter is from Essential PHP Tools: Modules, Extensions, and Accelerators, by David Sklar, (Apress, 2004, ISBN: 1590592808). Check it out at your favorite bookstore today.
Buy this book now. |
Next: Hidden, Select >>
More Graphic Design Articles
More By Apress Publishing