Working with Text Areas


Text areas are multiline fields for text input, as Figure 68.12 shows.

Listing 68.12. View Source for Figure 68.12.
 <form>   <textarea name="typeTextHere" cols="50" rows="5">Type text here.</textarea> </form> 

Figure 68.12. Use text areas for multiline text input.


The cols attribute of the textarea tag gives the horizontal size of the text area in characters, not pixels, while the rows attribute determines the vertical size of the text area in the number of lines. So, the example in Figure 68.12 is 50 characters wide and 5 lines tall.

The preset text of a text area appears between the textarea tags, not in a value attribute as with other widgets. If you don't want preset text, don't include any:

 <textarea name="typeTextHere" cols="50" rows="5"></textarea> 

GEEKSPEAK

In virtual wrapping, the form submits the text in the text area without extra carriage returns. In physical wrapping, the form submits the text with carriage returns at the end of each line.


By default, the text in a text area doesn't wrap. As the visitor types, the browser adds the new characters to the current line. Pressing Enter or Return causes a carriage return, and a new line begins.

The wrap attribute of the textarea tag changes this property. Setting this attribute to virtual or physical does the job:

 <textarea name="typeTextHere" cols="50" rows="5" wrap="virtual"></textarea> 

The type of wrapping affects the way the browser submits the form data. In virtual wrapping, the text appears to wrap in the text area, and the form submits the text as a continuous string of characters, without carriage returns (unless the visitor expressly creates them by pressing Enter or Return). In physical wrapping, the form submits the text exactly as it appears in the text area, complete with carriage returns at the end of each wrapped line.



Web Design Garage
Web Design Garage
ISBN: 0131481991
EAN: 2147483647
Year: 2006
Pages: 202
Authors: Marc Campbell

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net