|
Webteacher Software now offers
function encode(text) { Ref="0123456789abcdefghijklmnopqrstuvwxyz.-~ABCDEFGHIJKLMNOPQRSTUVWXYZ" Result="" for (Count=0; Count<text.length; Count++) { Char=text.substring (Count, Count+1);} document.form1.result.value=Result }
First we defined a variable to contain every letter and number
Ref="0123456789abcdefghijklmnopqrstuvwxyz.-~ABCDEFGHIJKLMNOPQRSTUVWXYZ" For example, in the English alphabet, I could easily create a code such that A=1 and B=2 because A is the first letter, and B is the second. Ref allows me to create the same code, but it includes all possible leters and number s. The letter 'a' returns a value of 10 because it is the 10th letter in from the left. (Actually it's the eleventh, but JavaScript begins counting with zero just to keep us on our toes). Later we will use the command Num=Ref.indexOf(Char) to locate the letter Char inside Ref and assign its position (how many places in) to the variable Num We'll discuss the indexOf property in more detail later.
The second line of the function, Result="" is sometimes called "priming" a variable. This statement establishes that a variable called Result does exist, and that it can contain text, but does not conatin any right now. Later, I will tack letters on to the end of Result, so I need to have it in place.
| ||
Home | WebData - Web Database Software | Javascript | CGI | Consulting | Map Builder | Contact Us | The Press Room |