javascript - Using a variable created in a different page -


there 2 javascript variables in index.html page. want use these 2 variables in control.js.

index.html has jquery script below

<script> $(document).ready(function() { // load select code country.html $('#selectcourse_country').load('country.html select', function() {     // when country selected     $('#selectcourse_country select').change(function() {         // id         var countryid = $(this).children('option:selected').val();         // load select code state.html id         $('#selectcourse_state').load('state.html #'+countryid,function(){             $('#selectcourse_state select').change(function(){                 var stateid = $(this).children('option:selected').val();                //alert(stateid);                                 });         });     });   }); }); </script>  

i want use value of variables countryid , stateid in control.js. how can pass them index.html control.js.

make global container in project can contain object. , objects can access globally in js page of application.

window.global ={country_id : countryid , state_id : stateid}; 

then use them in control.js :

var contid =window.global.country_id; var statid =window.global.state_id; 

Comments