Tips and Examples :

1.Variable declaration with 'var' keyword.

Always use 'var' keyword before variable name, during the declaration of the variable.If u dont use 'var',it may show errors in some browsers like IE.

2.Never use javascript keyword as variable name.

3.Life time of javascript variables.

If you declare a variable, using "var", within a function, the variable can only be accessed within that function. When you exit the function, the variable is destroyed. These variables are called local variables. You can have local variables with the same name in different functions, because each is recognized only by the function in which it is declared.

If you declare a variable outside a function, all the functions on your page can access it. The lifetime of these variables starts when they are declared, and ends when the page is closed.

4.javascript form submit

We can submit a form without submit button,i.e on onclick event of a button we will submit the form inside the javascript function.

Example :
            <script>
                function form_submit() {
                document.form1.action="validate.php";
                if(document.getElementById('name').value){
                   document.form1.submit();
                }else{
                   alert('this field should nt be empty');
                }
                }
            </script>
            

5.Name of a submit button should not be submit otherwise it may show error in IE.

6.difference between # and javascript:void(0);

Both will stop the linking to any location.
<a href="# "> - used for book mark .It is concatenated with the url.
<a href="javascript:void(0) "> - no effect

7.To get Text of Options :

Example :
            <script>
               function showText(obj){
               var text=obj.options[obj.selectedIndex].text;
                alert(text);
                }
--------------------------------------------------------------------------    
                
            </script>
            

8."this" keyword :

The "this" is special keyword in JavaScript. It is used to refer to the object on which a method is being invoked.

Example :
            <script>
               var radius = 20;
                function printradius()
                {
                   document.write(this.radius);
                }
                printradius();
            </script>