Thanks. How can I mark this as answered?
On Friday, May 18, 2012 4:47:28 PM UTC+2, shumway wrote:
>
> Hello,
>
> I am trying to pull data from a google spreadsheet, put it into a
> multi-dim array, and then use the different elements of the array to
> populate drop boxes. I can't seem to get it to work correctly.
> Specifically the issue seems to lie with in this statement:
>
> var row = new Array();
> for (var i = 0; i < numRows; i++) {
>
> for (var j = 0; j < numCols; j++) {
>
> row[i][j] = response.getDataTable().getValue(i,j);
> // alert(response.getDataTable().getValue(i,j));
> }
> }
>
> Here is the full script:
>
> <html><head><title>1805</title>
>
> <script type="text/javascript" src="http://www.google.com/jsapi"></script>
> <script type="text/javascript">
> google.load('visualization', '1', {'packages':['table']});
>
> function onldQuery(){
> var
> url='https://spreadsheets.google.com/a/finance-in-motion.com/tq?tq=select
> A,B,C &key=XXXXXXXXXXXXXXXXXXXXXXXX';
> var query = new google.visualization.Query(url);
>
> query.send(handleOnldResponse);
> }
>
> function handleOnldResponse(response){
>
> if (response.isError()) {
> alert('Error in query: ' + response.getMessage() + ' ' +
> response.getDetailedMessage());
> return;
> }
> var data = response.getDataTable();
>
> var numRows = response.getDataTable().getNumberOfRows();
> var numCols = response.getDataTable().getNumberOfColumns();
>
> var row = new Array();
> for (var i = 0; i < numRows; i++) {
>
> for (var j = 0; j < numCols; j++) {
>
> row[i][j] = response.getDataTable().getValue(i,j);
> // alert(response.getDataTable().getValue(i,j));
> }
> }
> alert(row);
> var dd = document.getElementById("Username");
> var sb = document.getElementById("secondBox");
>
>
> for(var i = 0; i< row.length; i++){
>
> dd.innerHTML += '<option>'+row[i]+'</option>';
> sb.innerHTML += '<option>'+row[i][1] +'</option>';
> }
>
> }
>
>
> function queryGet(){
>
> var chose = document.getElementById('Username').value;
> var select = 'select A,B,C where A contains ' + chose;
> var url='https://spreadsheets.google.com/a/finance-in-motion.com/tq?tq=' +
> select + '&key=0AjV_Fr31Owm1dHJpVDVDYVNQM3pxVnBlUEtDR1RWb1E#gid=0';
> var query = new google.visualization.Query(url);
> query.send(handleQueryResponse);
>
>
> }
> function handleQueryResponse(response) {
> if (response.isError()) {
> alert('Error in query: ' + response.getMessage() + ' ' +
> response.getDetailedMessage());
> return;
> }
> var data = response.getDataTable();
> visualization = new
> google.visualization.Table(document.getElementById('queryDisplay'));
> visualization.draw(data, null);
> }
>
>
>
>
> // }
> </script>
> </head>
>
> <body onload="onldQuery()">
> <form>
>
>
>
> <select id="Username"></select>
> <select id="secondBox"></select>
>
>
>
>
>
>
> <input type="button" value="Submit" onclick="queryGet()" />
>
> </form>
> <div id="queryDisplay"></div>
> </body>
>
> </html>
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/tEmC1En3hIsJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.