0

I have below code. I am getting time from other page via get method into feedback.php.

Now I need to pass this value from feedback.php to chart.js on this line ['Time taken by you is', time] then it will dispay chart on feedback.php page. How can I get this things done?

feedback.php

 <script src="chart.js"></script>
 <div id="chart_div"></div>
 <div id="chart_div"></div>

  **<?php $time= $_GET["sec"];?><br>**

chart.js

  var data = google.visualization.arrayToDataTable([
    ['Time', 'Time taken by worker'],
    ['Worker 1 ', 200],
    ['Worker 2', 150],
    ['Worker 3', 300],
    ['Worker 4', 160],
    ['Worker 5', 140],
    ['Time taken by you is', time]
  ]);
1

1 Answer 1

1

Try Below

Define Time Var before load chart.js

<script>
    var TIME_VAR = '<?=$_GET["sec"];?>';
 </script>

Then load <script src="chart.js"></script>

In chart.js you can use TIME_VAR

var data = google.visualization.arrayToDataTable([
    ['Time', 'Time taken by worker'],
    ['Worker 1 ', 200],
    ['Worker 2', 150],
    ['Worker 3', 300],
    ['Worker 4', 160],
    ['Worker 5', 140],
    ['Time taken by you is',TIME_VAR]
  ]);
Sign up to request clarification or add additional context in comments.

1 Comment

Working perfectly :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.