Including JavaScript in PHP function Error
<p>I had a weird problem here. Please check the code below. I do not understand how this code below is created by somehow part of it is working, considering mixture of php variables and javascript variables. </p>

<p>First, let us see what the alert() outputs (take note that $lat and $lng is different from the array $vlat):</p>

<ol>
<li><p>In Line 8 of the code below, alert(eventlocation) properly displays the coordinates of the GoogleMap latlng (so the implementation is correct)</p></li>
<li><p>In Line 13, alert(s) was able to display incrementing values (i.e. 0,1,2,3,4,..) based on the for loop in the previous line so it is also correct.</p></li>
<li><p>In Line 14, alert($vlat[0]) was able to display the latitude of the first element of that array (declared before this set of codes) so it is also correct</p></li>
<li><p>In Line 15, alert($vlat[1]) was able to display the latitude of the second element of that array so it is also correct</p></li>
<li><p>But in Line 16, alert($vlat[s]) displayed undefined.</p></li>
</ol>

<p>Can anyone explain that? Thanks</p>

<pre><code>    echo "&lt;script src= 'http://maps.google.com/maps?file=api&amp;amp;v=2&amp;amp;key=ABQIAAAA2jrOUq9ti9oUIF0sJ8it1RTNr3PHi_gURF0qglVLyOcNVSrAsRRu2C3WQApcfD0eh9NLdzf9My0b9w' type='text/javascript'&gt; &lt;/script&gt;
    &lt;script language='javascript' type='text/javascript'&gt;
    function getabc(){
        var eventlocation;
        var volunteerlocation;
        var s;
        eventlocation = new GLatLng($lat, $lng);
        //alert(eventlocation);
        var volunteerDist = new Array();
        s = $ctr;
        var tvid = new Array();
        for(s=0;s&lt;$numrows;s++){
            //alert(s);
            //alert($vlat[0]);
            //alert($vlat[1]);
            //alert($vlat[s]);
        }
    }
    a = getabc();     &lt; /script&gt;";
</code></pre>
