jeudi 23 avril 2015

use result of variable from one function to another function

I need to use variable generated value from first function (variable url), in second function, here is a code:

var kategorije = ["c1", "c2", "c3", "c4", "c5", "c6"];
var url;

function checkbox_test() {  //first function
// calculating url ...
alert(url); // here everything is ok, something like c1=x&c2=a&c3=5 ...

function loadXMLDoc()   {  // second function
   regid = "123456abcdefg";
   var xmlhttp;
   xmlhttp=new XMLHttpRequest()
   xmlhttp.onreadystatechange=function()    {
     if (xmlhttp.readyState==4 && xmlhttp.status==200)  {
            }"GET","" + regid + '&' + url, true);
   alert(url); // just checking is value of url is correct! here it say url is undefined!

I need to pass value of url generated in first function in GET as url. Thanks!

Aucun commentaire:

Enregistrer un commentaire