I've got a variable in a js script, which I want to set from a php script and access from my js script.
How can I do this in good coding style manner.
At the moment I use a global variable in the js script for that purpose :(
Setting the variable from PHP:
$js = '<script type="text/javascript">';
$js .= "g_sourceType = '$sourcetype';";
$js .= "</script>\n";
Defining and accessing it in my js script:
var g_sourceType; // at global scope
...
function SetSubmitFocus()
{
switch (g_sourceType) {
...