Jump to content

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

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.