Title: Tutorial #2: Variables Post by: Agent Moose on May 19, 2009, 09:32:08 pm What is a Variable?
A variable is a "container" for information you want to store. A variable's value can change during the script. You can refer to a variable by name to see its value or to change its value. Ok, How do I use them? There are two ways you can start out a variable. You can use this; Code: <script> Or, you can use a shorter way: Code: <script> It doesn't matter which one you use. A very inportant thing, you may have a variable named whatever you want, as long as there are no spaces. So, you can use this: Code: <script> Code: <script> Code: <script> What exactly would I use them for? As you read above, variables are "containers". They can hold HTML, or text, or even other scripts just as Jquery and Javascript codes. Here is an example of useing a variable for text... Code: <script> Just a little note, the ";", it is good to have that at the end of everyline when ever you are doing javascript, but you don't have to. It just says that that line is done. Now, that will not show anywhere because it doesn't have anything to make it show. To make it you would use this... Code: <script> You may use HTML in the variables. Just one thing you need to remember, you can't use double quotes, you must use Single Quotes. Now for somthing that is a bit harder. Code: <script> Now useing the variables in an if...else statement. Code: <script> Title: Re: Tutorial #2: Variables Post by: Andrew on May 20, 2009, 07:37:21 am Very nice agent, this helps of understand codes a bit more. great tut :)
Title: Re: Tutorial #2: Variables Post by: Agent Moose on May 20, 2009, 07:45:46 am Glad you like it :) I've got 3 more tutorials that will help you so you can start coding, if you want to :P
Title: Re: Tutorial #2: Variables Post by: Andrew on May 20, 2009, 12:17:06 pm Too bad i cant code on a phone.... but i will start soon, probally this weekend. |