events - Running a javascript function based on statechange -


following answer in stackoverflow question, trying run following code. myfunction takes 1 google visualization event. following code valid? or how handle multiple statechange google visualization events in single function?

var categorypicker1, categorypicker2; function drawvisualization() {   // etc.   categorypicker1 = // etc...    categorypicker2 = // etc...    // register hear state changes.   google.visualization.events.addlistener(categorypicker1, 'statechange', myfunction);   google.visualization.events.addlistener(categorypicker2, 'statechange', myfunction);    // etc. }  function myfunction() {   var whereclauses = []; if (categorypicker1) {     whereclauses.push("something1 = '" + document.getelementsbyclassname('goog-inline-block goog-menu-button-caption')[0].innerhtml + "'") } if (categorypicker2) {     whereclauses.push("something2 = '" + document.getelementsbyclassname('goog-inline-block goog-menu-button-caption')[1].innerhtml + "'") } whereclause = whereclauses.join(" , ");  // something.... } 

not clear question, assume you're building sql query database selected items in categorypicker. despite being extremely bad/dangerous thing (building sql client side, , sending server), should possible grabbing selecteditems categorypicker, , joining them " , ". like:

values = categorypicker1.getstate().selectedvalues; values = values.concat(categorypicker2.getstate().selectedvalues); var args = values.map(function(_) { return "'" + _ + "'"; }); console.log(args.join(" , ")); 

i wouldn't if you. pass arguments server, , remap them there (after appropriately filtering them, etc). again very dangerous.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -