<?e>Free Webde? Tutorials::aring Va?les and Func??itle>

Web Designing Made Ea?/p>

<?align="top"> <?e width="800" bo?="0" cellpadding="15" cellspacing="0" bgColo?376B99"> <?eigh?3" valign="top" bgcolor="#1B5389ass="topbg">&nbs?

Crea���?���?Websites

<? ble> <?
Add ?avou??>

 Print this Page

<?align=right> <?form action="htt???e.google.com/transla??et="_top">
?form action="htt???e.google.com/transla??et="_top">

Web <? Thi??font>
HTML Tu?al

Ja?? Tutorial

CSS Tu?al

PHP/ASP

CGI T?ial <?

F?FTP Tool<

Free web??ont>

Free Bullets

Free Templa?/fon?a>F?Logo?ont>

Tu?alsFree Ke?ds Software

Free Web Tools Free JavaScrip?font>

Free Web Tools

<?
Quick Links

Tell a F���?d

S??Tuto?

LinksFree Resources

Tran?e a ?age in your Lang?Ea?oney with yo?ebsi?font>

Free Websi���?���?���?n <?ign="lef? S??ns

<?ign="lef?font color="#FF0000">META Tag Generator

<?ign="lef?font color="#FF0000">HTML Enc?or

<?ign="lef?font color="#FF0000">?"checksi?hp">Check Site Pop?ity

Sea?Suggestion Tool

Menu Gene??ont>

Ads Network

Valid CSS!

align="center">Other Services

<?
HomeHome |Adverti���?���?h=Adve?e | Contact U?> | Free Re?ces ?g src="Image?il1.gif" alt="Submit a T?ial" wid?32" height="32" /> Declaring Va?les and Func??ont>
<?ign="lef?Adding ?able?d functions ?our ??/span> Now it's time to get into some reall?n st? Yes, va?les and func??on't wor?it's not as bad as i??.....let's s? with declaring ?able?ou'll want to keep all of yo?ariables in ?HEAD sec? for now. Place ?declarations? the SCRIPT ? inside ?head sec? of ? doc??/fon??

To decla? variable in JavaScript, you will write ??g like this:

<?ign="lef?&l?AD>
<SCRIPT language="JavaScri?
<!--hide from old bro???
?name=val?

//--&g?? </SCRIPT>
</HEAD> Here is ? the?ommands mean:

  1. var
  • name
    This is ?name you give the va?le. Give it any name you like (o? than a JavaScri?eser?? such as "function" or "onMo??.).

  • value
    This is ?initial ?e yo?nt the variable ?ave. It can be a number, words, ?, false, or null.
  • <? cla?heading">Using N???>

    You can assign a number ?e to a variable by placing the desired n????= sign:

    var cars=3; You can also use a n??? decimal. Ja?? isn't too picky abo?hether the value is an integer o?cimal. J?? it in.

    align="left"> var cos?95;

    U? Strings
    A ?ng i?? gro?f charac?, such a??ence or a wo?To define a ?ng, ?? need to place single or double ?e ma?around the value, like this: ?movie="The Lost World";

    Also, if yo?ace numbers inside the q??hey are ??as a string ?er than a numerical ?e. Boolean Values

    This one i?ce. Assign the variable a value of t?or false. No quo?needHere's an example: <?ign="lef?font color="#FFFFFF"> va?ory=?;

    <? cla?heading">The null Value

    If ?declare ??g as null, i?ans nothing. Not even ze?just plain nothing. Here's the forma?/fon?div> <?ign="lef?font color="#FFFFFF"> va?mone?ll;

    Well, nothingne?? so grea? thi??but it can be useful when yo?e prompt? get informa? from viewer?nd they ? in......nothing!

    <? cla?heading">Case Sensitivit??

    Unlike alot of things in HTML, Ja???e ca?ensi?. Soariable named "john" is not ?? as "John" o?OHN". The same goes for commands and functions and so on. Ju?emember ? case when you u?avaScrip?or you may get e? cit??d of nif?ffec?..

    Semicolo?>

    Don'?? tho?emicolon?hey are ? to ?? JavaScript commands and declara??nd can also cause er?city if ? are lef?f. I did thi?few ??nd i?kes for ? pre?? stuff when ???oad ??!

    F?ions!

    Well, functions a???ake ?gs more organized and readable. A function i??of JavaScrip?atements put togethe???le p??You ? wan? kee???ions inside ?PT tags inside the HEAD ?ion. Here is the format for a function decla?on:

    <HEAD>
    <SCRIPT language="JavaScript">
    function name (?mete??mete?
    {
     JavaScri??ment?d declarations
    ??
    //-->
    </SCRIPT>
    </HEAD>

  • func?
    Indicates that ?are going to create a function.
    1. i> name
      Thi? the name yo??he f?ion. As befo?name it ?ever you like. <?ign="lef?

    2. (pa??, pa??)

    3. {
      This symbol lets you begin adding Ja?? sta?nts and declarations.

    4. ?>
      This indicates the end of ??emen?and ?end of the f?ion.
    <?ign="lef?font color="#FFFFFF"> To make use of the function, you will make a c?he f?ion ? you wan? use it. You call a func? by ?g the name, any ?mete?ou want ?end, and a semicolon, like this:

    <?ign="lef?font color="#FFFFFF"> function dosomething (mymoney, cos?

    Place ? mou?ere!

    <?ign="lef?font color="#FFFFFF"> No?ere'?e code that gene?d the link. See if you can work ? way through it. I'll ex?n it at ?end of the scrip???

    <HEAD>
    &l?-hide ??=" "; func? ove?k (text)
    {
    window.??ext;
    }
    function offlink (t
    {
    window.??ext;
    }

    //-->
    </SCRIPT>
    </HEAD> &l?DY>

    <A HREF="java7.ph?nMou?er="overlink('Functions Rule!');???
    onMouseout="offlink(' ');return tr? Place your mouse he?lt;/A>

    </BODY>

    What ?..? Yes, in ? case the sc? is much longer and ??me time ?ork ?? Here's ? the script is doing:

    <? cla?heading">In ?HEAD Sec?
    1. var tex?";
    1. func? ove?k(te?/b> declare?func? named o?ink. The function re?es the variable ? to be sent ?? order to wo???
    2. {
      Beg?JavaScri??ment??e function o?ink.
    3. windo?atus=tex?b>

    4. ?>
      Ends the s?ment? the function overlink.

  • function offlink (?)
    This decla?a function named offlink. The function requi???able tex? be ? to it in order ?ork ?erly.

  • ?ow.s???br /> This places ??e of the variable te?n the status bar. The value of text ?? to ?func? when it was called inside the link ? which i?e st? " ". See the ex?nation of the link tag for more. h3 align="left">In the BODY Section
  • <A HREF="jvar.php" onMouseove??ink('Functions R?');return tr?
    onMouseout="offlink(' ');re? true"> Place yo?ouse here!&l?>
    <?ign="lef?font color="#FFFFFF"> This tag calls both of the functions and passe? a s?g which is a?ned ?he variable named te?The firs?nction, overlink, is called inside the onMou?er command. This means that ? the use?aces their mouse ove?e link, ??emen?nside the function o?ink ? be exec?. As you can see, overlink i?lled with a ?ng variable inside the ( ) s?ls. Notice we use single quo??efine this s?g, since double ?es a??in the onMou?er command. The ?ng value we ?e he??at i?nt to the function o? and thu? wha?ds u? the sta?bar. So, "Functions Rule!" i?at shows up in the s???en the mouse moves o??link. The onMouseout command calls the f?ion named offlink when the mouse moves a?from the link. This ?, we assigned the va?le text a value of blank space. The blank space is sent ?he f?ion, and is ???he s????ng the "Func??le!" string befo??he return tr?hrases a?here to make sure the sc? works b??ing ?.

    Well, if ?made it ??all of that, you are ready to mo?n. If yo?ill don'?have a handle on it ? try wri? out the script on your comp?, or even by hand. Sometimes it help???our ????mess??

    <?ign="lef?font color="#FFFFFF"> Well, let'??n to some mo?echnical stuff, in the next ?ion:

    Previo���?���?h=

    &nbs??

    &nbs??