views:

59

answers:

0

I have a form, where a user selects a chart from the Google Graph API. These variables are submitted to the URL, via the GET method (this has to happen, I can't do POST).

<form name="chart" method="get" >
   <select name="chartType"
   <option name="oMeter" 
        value="http:\/\/chart.apis.google.com\/chart?chxl=0:|0|50|100&chxt=y&chs=300x150&cht=gm&chd=t:' + obj[sensorName] + '&chds=0,100&chl=' + obj[sensorName] + '&chtt=' + sensorName">
Analog Meter
   </option>
   </select>
</form>

Once they are submitted, I pull the GET variables out.

//retrieve all GET variables in url

$.extend({

   getUrlVars: function(){
     var vars = [], hash;
     var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
     for(var i = 0; i < hashes.length; i++) {
       hash = hashes[i].split('=');
       vars.push(hash[0]);
       vars[hash[0]] = hash[1];
     }
     return vars;
   },

   getUrlVar: function(name){
     return $.getUrlVars()[name];
   }

 });

 //create GET variable object
 var allVars = $.getUrlVars();
 var chartType  = $.getUrlVar('chartType');

Then, I display the graph like so:

var obj = jQuery.parseJSON(JSON.stringify(msg));
document.getElementById("graph").innerHTML = "<img src='" + chartType + "'/>";

I can't for the life of me figure out how to get the chart to come through correctly; I know my object[sensorName] stuff comes through correctly after JSON parsing. What am I doing wrong?