title: Using javascript variables from another function
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/6024748/how-to-know-variables-from-different-namespaces">How to know variables from different&hellip;&ldquo;namespaces&rdquo; ?</a>  </p>
  </blockquote>
  
  
  
  <p>I have a webphone integrated into our webpage, and when a call comes in, a javascript function records the caller's number (e.g. <code>01234 123456</code>) and saves it as the variable <code>inCallingNum</code>.</p>
  
  <p>I need to use this variable in a different function which sends information to a php page and stores it on our database.</p>
  
  <p>Is it possible to access the javascript variable from another function at all, and if not what is the easiest way to get around it?</p>
  
  <p>Edit: This is the code I have, which currently captures the inCallingNum variable</p>
  
  <pre><code>    function webphonetojs(varr)
          {
              var eventNotify = '' + varr; 
              //alert("eventNotify = "+eventNotify);
              displaystatus('WEBPHONE SAY: '+eventNotify);
  
              initcheck();
              var chanelStat = applethandle.API_GetStatus(1); //  get line status
              var chanelStatus = chanelStat.replace(/\s+/g,'');
              if (chanelStatus == 'Ringing')
              {
                  var incomming = eventNotify.slice(eventNotify.lastIndexOf(",")+1, eventNotify.length);
                  if (incomming == '2')
                  {
                      var inCallingNum = eventNotify.split(",", 4); inCallingNum = inCallingNum.toString();
                      inCallingNum = inCallingNum.slice(inCallingNum.lastIndexOf(",")+1, inCallingNum.length);
                      displaystatus('CALLER IS: '+inCallingNum);
  
  }
  }
  }
  </code></pre>