Using PHP parameter in Javascript -


i have parameter of php of $test1, want add scenario in js if $test1 exists, show coding in javascript. have drafted code follow , doesn't work. may cause?

        <script type="text/javascript"><!--             mychart.setxmldata("             "<categories>" +                 "<category label='1'/>" +                 "<category label='2'/>" +             "</categories>" +             if($test1['transactions_tmp']) {             "<dataset>" +                 "<set value='147400'/>" +                 "<set value='189100'/>" +             "</dataset>" +             }             "</chart>");         // -->         </script> 

try this:

<script type="text/javascript">             mychart.setxmldata(             "<categories>" +                 "<category label='1'/>" +                 "<category label='2'/>" +             "</categories>" +             "<?php if($test1['transactions_tmp']) { ?>" +             "<dataset>" +                 "<set value='147400'/>" +                 "<set value='189100'/>" +             "</dataset>" +             "<?php } ?>" +             "</chart>");  </script> 

Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -