Jump to content

Passing data through google api


Kris1988

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/293877-passing-data-through-google-api/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.