Goto Lesson:
Lesson 1 Lesson 2 Lesson 3 Lesson 4 Lesson 5 |
The coolest feauture of Javascript is its ability to understand and use algebraic functions to swap stuff and perform mathmetic functions. This is very useful because you make it so when the use clicks on something the script will process it and change stuff around accordingly. To swap me must first have some variables to put stuff in. You must initiate your variable it is alphanumeric, but must start with a letter and have no spaces. The command to initiate a variable is simple var. One very important point we must go over is that every line of code must ended with a semicolon, this tells separates commands if you do not do this you will get errors. This is usually the first thing you should check for when debugging a page. Lets see an example:
<script language="Javascript"> <!--Hide var myvar1; var myvar2=82; var myvar3="hello"; //end--> </script> Our first variable was just defined and nothing was assigned to it which means it is equal to zero right now. Our second variable contains the number 82 (no quotes around numbers). Our Final variable contains the text hello and text must have quotes. That is all you need to know about assigning variables now lets learn what to do with them. |