Banner Ad

    A    L    W    A    Y    S           D    E    S    I    R    E           T    O           L    E    A    R    N           S    O    M    E    T    H    I    N    G           U    S    E    F    U    L   

Sunday, September 1, 2013

How to define static javascript variable

<script type="text/javascript">
checkadid.count=0;
checkadid.adid="";



function checkadid(checkbox)
{

checkadid.adid=checkadid.adid.concat(checkbox.value);

    if (checkbox.checked)
    {
        
    }


}

</script>


here my javascript static variable is checkadid.adid
since javascripts are weakly type there is no hard and fast rules you need to define variable as above

and i used this static variable access to following java script function


function load_table(){


 
var aid=checkadid.adid;
 
if(aid.length<=6){
 
alert("Please select at least 2 advertistment")
 
}
else{
     window.location.href="<?php echo site_url('controller_c/compareVehicles/ctable'); ?>?aid="+aid;

}

  }



static java script variable can access from any where within any javascript function

Click here to learn about javascript variables





0 comments:

Related Posts Plugin for WordPress, Blogger...

your comments