Note that there are some explanatory texts on larger screens.

plurals
  1. POPassing variable values from Php to Javascript
    primarykey
    data
    text
    <pre><code> &lt;!DOCTYPE HTML&gt; &lt;html&gt; &lt;head&gt; &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8"&gt; &lt;title&gt;Highcharts Example&lt;/title&gt; &lt;script type="text/javascript" src="js/jquery.min.js"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(function () { var newanswer = &lt;?php echo"$newanswer"; ?&gt; var chart; $(document).ready(function() { chart = new Highcharts.Chart({ chart: { renderTo: 'container', type: 'column' }, title: { text: 'Monthly Progress Reports' }, subtitle: { text: 'Source: Sales Department' }, xAxis: { categories: [ 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec' ] }, yAxis: { min: 0, title: { text: 'Range' } }, legend: { layout: 'vertical', backgroundColor: '#FFFFFF', align: 'left', verticalAlign: 'top', x: 100, y: 70, floating: true, shadow: true }, tooltip: { formatter: function() { return ''+ this.x +': '+ this.y +' Star'; } }, plotOptions: { column: { pointPadding: 0.2, borderWidth: 0 } }, series: [{ name: '5 Star', //Blue data: [newanswer, 20, 30, 40, 50, 60, 70, 80, 90, 95, 10, 20] }, { name: '4 Star', //Red data: [4, 20, 30, 40, 50, 60, 70, 80, 90, 95, 10, 20] }, { name: '3 Star', // Green data: [3, 38.8, 39.3, 41.4, 47.0, 48.3, 59.0, 59.6, 52.4, 65.2, 59.3, 51.2] }, { name: '2 Star', //violet data: [2, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1] }, { name: '1 Star', //lightblue data: [1, 33.2, 34.5, 39.7, 52.6, 75.5, 57.4, 60.4, 47.6, 39.1, 46.8, 51.1] }] }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;script src="js/highcharts.js"&gt;&lt;/script&gt; &lt;script src="js/exporting.js"&gt;&lt;/script&gt; &lt;div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"&gt;&lt;/div&gt; &lt;?php $newanswer = 50; ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>is this possible to pass a php value to a javascript? i need to do it in order to put the value of the query of mysql into the graph and the graph is coded by java script. thx</p> <p>the problem is this line</p> <pre><code>&lt;?php $newanswer = 50; ?&gt; </code></pre> <p>cant pass the value on this line:</p> <pre><code> var newanswer = &lt;?php echo"$newanswer"; ?&gt; </code></pre> <p>so that the <strong>50</strong> value dont show in this line: </p> <pre><code> data: [newanswer, 20, 30, 40, 50, 60, 70, 80, 90, 95, 10, 20] </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload