How do I pass php GET parameters through to a JavaScript routine?

I am using PHP, MySQL, JavaScript, XML/SWF Charts (which is great) but it has a line...

'FlashVars', 'library_path=charts_library&xml_source=my_chart_xml.php',  in a call to the main JavaScript interface .... I want to call the my_chart_xml.php with a variable parameter, e.g....

'FlashVars', 'library_path=charts_library&xml_source=my_chart_xml.php?myparam=$value',

how do I do that?
me_patrickAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

hieloCommented:
somewhere you probably have:
echo "...'FlashVars', 'library_path=charts_library&xml_source=my_chart_xml.php?myparam=$value', ...";

try:
echo "...'FlashVars', 'library_path=charts_library&xml_source=my_chart_xml.php?myparam=" . encodeurl($value) . "', ...";
0
me_patrickAuthor Commented:
No, it's a parameter to a call to javascript - it's all within a
<script language="JavaScript" type="text/javascript"> tag.

0
hieloCommented:
post what you have
0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

p_nutsCommented:
post a sample for us pls

 but I think howling is right. just add it to the file name.
0
me_patrickAuthor Commented:
This is the product I am using (which is very good) .... http://www.maani.us/xml_charts/index.php ... everything about how this works and can be used is there.

This is my actual call (through the JavaScript interface)   ....

        <script language="JavaScript" type="text/javascript">
        <!--
        if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
            alert("This page requires AC_RunActiveContent.js.");
        } else {
            var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
            if(hasRightVersion) {
                AC_FL_RunContent(
                    'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',
                    'width', '600',
                    'height', '400',
                    'scale', 'noscale',
                    'salign', 'TL',
                    'bgcolor', '#777788',
                    'wmode', 'opaque',
                    'movie', 'charts',
                    'src', 'charts',
                    'FlashVars', 'library_path=charts_library&xml_source=entries_chart_xml.php',
                    'id', 'my_chart',
                    'name', 'my_chart',
                    'menu', 'true',
                    'allowFullScreen', 'false',
                    'allowScriptAccess','sameDomain',
                    'quality', 'high',
                    'align', 'middle',
                    'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                    'play', 'true',
                    'devicefont', 'false'
                    );
            } else {
                var alternateContent = 'This content requires the Adobe Flash Player. '
                + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
                document.write(alternateContent);
            }
        }
        // -->
        </script>

Basically I just want to pass parameters through this interface between the calling php code (which is the wrapper for the interface), and the subordinate php routine that actually does the work (see the FlashVars line above).

I'm getting around this at the moment by creating a session variable and then picking it up but I just imagined there would be a more direct way of doing it - no?



0
hieloCommented:
try:
<?php
//these are the parameters you want to send
$paramsForXML=array(	"username"=>"johnny"
					,"password"=>"XXX"
					,"name"=>"john smith"
					,"status"=>"suspended"
				);
//this is the url where you want to send the request to
$url='entries_chart_xml.php?';
foreach($paramsForXML as $k=>$v)
{
	$url.= urlencode($k)"=".urlencode($v)."&";
}
$url=urlencode(substr($url,0,-1));

?>
 <script language="JavaScript" type="text/javascript">
       <!--
       if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
           alert("This page requires AC_RunActiveContent.js.");
       } else {
           var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
           if(hasRightVersion) {
                AC_FL_RunContent(
                   'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',
                   'width', '600',
                   'height', '400',
                   'scale', 'noscale',
                   'salign', 'TL',
                   'bgcolor', '#777788',
                   'wmode', 'opaque',
                   'movie', 'charts',
                   'src', 'charts',
                   'FlashVars', 'library_path=charts_library&xml_source=<?php echo $url; ?>',
                    'id', 'my_chart',
                   'name', 'my_chart',
                   'menu', 'true',
                   'allowFullScreen', 'false',
                   'allowScriptAccess','sameDomain',
                   'quality', 'high',
                   'align', 'middle',
                   'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
                   'play', 'true',
                   'devicefont', 'false'
                   );
            } else {
                var alternateContent = 'This content requires the Adobe Flash Player. '
               + '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
               document.write(alternateContent);
            }
       }
       // -->
       </script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
me_patrickAuthor Commented:
Thanks Hielo - that was the answer to that. Now (only sometimes) for some reason the chart is not responding to changes in the underlying charting data .... very puzzling but a different question alltogether.
You've been a great help.
Patrick.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.