|
Webteacher Software now offers
A few text properties Here are a few of the text properties which we use in this function. There are properties for every type of object on your page. After you are through with this tutorial, you will be able to look up other properties from Netscape's Referenc e Page and understand how to use them. You can extract information about a piece of text by referring to one of that variable's properties. The length property tells me how many characters long a text string is. If I want to display an alert box with how many letters I typed, I would type alert(text.length).
If I wanted to find the first character of a piece of text I would use the substring property. Unlike length, the substring property needs additional information in parentheses, specifically how many places in to start and stop. Remember t
o alway
s subtract 1 from how many characters places you want, because JavaScript begins counting the first letter as zero.
The opposite of Substring is the indexOf property. Instead of returning the text at a certain position, it returns the position of a certain piece of text. For example, if I set MyText equal to "Tupperware" then the property MyText. indexO f("r") would return a value of 5. "r" is the sixth letter in, but again, JavaScript begins counting with zero.
The += operator allows me to add text to the end of an existing variable. For example, if the variable MyText="cat" then the command MyText+="erpillar" would result in MyText equalling "caterpillar." This example will tack anything you type onto the word "cat."
| ||||||||||
Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room |