Kris1988 Posted January 12, 2015 Share Posted January 12, 2015 (edited) Hi, I have a php script that generates a select dropdown box <option value="1"> Bob </option> <option value="2"> Tim </option> <option value="3"> Sam </option> <option value="4"> Phil </option> I then have the following javascript to produce my google api graph: <script type="text/javascript"> google.load('visualization', '1', {'packages':['corechart']}); google.setOnLoadCallback(drawChart); function drawChart() { var jsonData = $.ajax({ url: "test1.php", dataType:"json", async: false, }).responseText; var data = new google.visualization.DataTable(jsonData); var chart = new google.visualization.LineChart(document.getElementById('chart_div')); chart.draw(data); } </script> This then runs a php script that returns the data back in Json format. How can I pass the <option value=""> through the to the test1.php script to generate the json data based on the the value selected i.e 1, 2, 3 etc. i an new at javascript and the google api can anyone let me know how I can get this variable sent through by the google api script. and for the graph to refresh every time another option is chosen. Thanks kris Edited January 12, 2015 by Kris1988 Quote Link to comment https://forums.phpfreaks.com/topic/293877-passing-data-through-google-api/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.