JavaScript - Help With Programming Google Graphs With A Query
Hi, I have been trying to create a google graph from an input combobox but I'm having trouble passing the variable to the query on the spreadsheeet.
The graph is able to query the spreadsheet when I don't use a varible, and my combobox is recieveing the variable but I'm having trouble connecting the two. The code I'm trying to use is below and I also attached a text file, so any help would be so fantastic! This is the code I have for it: Code: <!-- try 1 Rivas, try 2 San jose You are free to copy and use this sample in accordance with the terms of the Apache license (http://www.apache.org/licenses/LICENSE-2.0.html) --> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <title> Google Visualization API Sample </title> <script type="text/javascript" src="http://www.google.com/jsapi"></script> <script type="text/javascript"> google.load('visualization', '1', {packages: ['linechart']}); </script><script src="http://www.google.com/uds/?file=visualization&v=1&packages=linechart" type="text/javascript"></script><script src="http://www.google.com/uds/api/visualization/1.0/3dc85ad905db9d2ce85ec8d8389c32d5/default,browserchart,linechart.I.js" type="text/javascript"></script> <script type="text/javascript"> function storeValue(obj){ if(obj.selectedIndex == 0){return;} var MonthChosen = obj.value; alert('You chose: '+ MonthChosen); } window.onload = function(){ document.getElementsByName('combo1')[0].onchange=function(){storeValue(this);} } var visualization; function drawVisualization() { // To see the data that this visualization uses, browse to // http://spreadsheets.google.com/ccc?key=pCQbetd-CptGXxxQIG7VFIQ var query = new google.visualization.Query( 'https://spreadsheets.google.com/ccc?key=0Ais9xMj35wQmdDBTMUxHRS1CRHVkcGI4dnZ0c2xLZXc&hl=en'); // Apply query language. query.setQuery('SELECT H WHERE E ="MonthChosen" ORDER BY F'); // Send the query with a callback function. 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.LineChart(document.getElementById('visualization')); visualization.draw(data, {legend: 'bottom'}); } google.setOnLoadCallback(drawVisualization); </script> <h2> What month would you like to see the 10 year comparative data from?</h2> <form> <table> <tbody><tr> <td>Combo Box</td> <td> <select id="combo1" name="combo1" onchange="input1.value = combo1.value"> <option value="’1’">January</option> <option value="’2’">February</option> <option value="’3’">March</option> <option value="’4’">April</option> <option value="’5’">May </option> <option value="’6’">June </option> <option value="’7’"> July</option> <option value="’8’">August </option> <option value="’9’">September </option> <option value="’10’">October </option> <option value="’11’">November </option> <option value="’12’">December </option> </select> </td> </tr> <tr> <td>Input Box</td> </tr> </tbody></table> </form> <div id="visualization" style="height: 400px; width: 400px;"></div> Similar TutorialsI am currently working on a project that requires me to get data from a mySQL database in order to create multiple (bar) graphs. I will then display these graphs in the corresponding location using Google Maps. I am having trouble trying to find out how to implement this. Do you guys have any suggestions. Thanks.
is there a ways in javascript to create graphs chart? i can't seem to find a code on the internet
Can anyone give me some advice on how to manipulate Google Fusion Table using Javascript??? I've read the Fusion table's Developer Guider. But still feel confused. Can anyone tell me the specific solution?? Or give me a sample code?? Thanks very much!!!!!! Hello here is another one i need suggestions on here is my coding so far <html> <head> <!-- New Perspectives on JavaScript Tutorial 3 Case Problem 2 Congressional Election Results Author: Date: November 14 2010 Filename: election.htm Supporting files: back.jpg, logo.jpg, results.css, votes.js --> <title>Congressional Races</title> <link href="results.css" rel="stylesheet" type="text/css" /> script type="text/javascript" src="votes.js"></script> <script type="text/javascript"> // script element to add the votes.js function totalVotes(votes){ // script element that will calculate the array var total = 0; for (var i = 0; i < votes.length; i++); { total = total + votes[i]; } return total; } function calcPercent(item,sum){ // script element to calculate the percentage which is rounded to the nearest integer var item = Math.round((item/sum))*100); // script element to get the percentage return item; } calcPercent(); function createBar(partyType,percent){ // script element to create blank cells switch(partyType) { case D: <td class='dem'></td> break; case R: <td class='rep'></td> break; case I: <td class='ind'></td> break; case G: <td class='green'></td> break; case L: <td class='lib'></td> break; } var barTxt = partyType; for (i=0; i < percent; i++){ document.write(barText); } } function showResults(race,name,party,votes){ // script element to display the results of a particular race var totalIV = totalVotes(votes); document.write("<h2>race</h2>"); document.write("<table cellspacing='0'>"); document.write("<tr>"); document.write("<th>Candidate</th>"); document.write("<th class ='num'>Votes</th>"); document.write("<th class='num'>%</th>"); document.write("</tr>"); for (var i=0; i < name.length; i++){ document.write("<tr>"); document.write("<td>name(party</td>"); document.write("td class='num'>"votes</td>"); var percent=calcPercent(votes[i], totalV) document.write("<td class='num'>(" + percent +"%)</td>"); createBar(party[i],percent) document.write("</tr>"); } document.write("</table>"); } </script> </head> <body> <div id="intro"> <p><img src="logo.jpg" alt="Election Day Results" /></p> <a href="#">Election Home Page</a> <a href="#">President</a> <a href="#">Senate Races</a> <a href="#">Congressional Races</a> <a href="#">State Senate</a> <a href="#">State House</a> <a href="#">Local Races</a> <a href="#">Judicial</a> <a href="#">Referendums</a> </div> <div id="results"> <h1>Congressional Races</h1> <script type="text/javascript"> showResults(race[0],name1,party1,votes1)... showResults(race[1],name2,party2,votes2)... showResults(race[2],name3,party3,votes3)... showResults(race[3],name4,party4,votes4)... showResults(race[4],name5,party5,votes5)... </script> </div> </body> </html> ______________ What i need to do is make a bar charts of elections people on the assignment, using 2 other files on a folder the names of the other files are votes.js and results.css here is the link of the actual question it is case problem 2 if u scroll down at http://books.google.ca/books?id=aG_T...Cell()&f=false right now i did up my coding and still nothing is working what does seem to be wrong with my coding? any suggestions from anyone? or hints even? thanks I have a page with a GoogleMap with a GoogleBar and I would like the GoogleBar to appear with something written in it already and to have that search executed. In other words, I would like to "write something to the GoogleBar and press Enter" automatically as soon as the map loads. How can I do this? btw: By GoogleBar, I mean the search bar that appears on the map after using the enableGoogleBar() function. Hi I recently started researching about programming and was interested right away. I'm new to all this and need a place to start. Any help would be greatly appreciated and look forward to posting on this forum. Hi, I'm not sure where I have translated this incorrectly. I have one google map embedded on my page which works fine. But I wanted to add a second one. I thought the easiest way to do this would be to have a second page which is called later on with all the details on it for the second map. However although I think (this I presume is where I went wrong) I have replicated the instructions correctly the place holder for the second map just remains blank. This is the code for my called page with the instructions for the second map: PHP Code: <?php echo $_POST['Map'] . '<br />'; ?> <div id="placemap_canvas"></div> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #placemap_canvas {width:100%; height:150px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM regions WHERE RegionPId='{$_POST['Map']}'"); while($row = mysql_fetch_array($result)){ echo $row['maplink']; } mysql_close($con); ?> ); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("placemap_canvas"), myOptions); } </script> And this is the script of the main page, just in case I would be better off keeping them both in one place. Code: <head> <script type="text/javascript"> function loadSubPlace(File,ID,Msg,Eile,EID,Esg){ loadXMLDoc1(File,ID,Msg); var mimer = setTimeout(function(){loadXMLDoc1(Eile,EID,Esg)},5000); } </script> <meta name="viewport" content="initial-scale=1.0, user-scalable=no" /> <style type="text/css"> html {height:250px} body {height:250px} #map_canvas {width:30%; height:250px;} </style> <script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=true" /> </script> <script type="text/javascript"> function initialize() { var latlng = new google.maps.LatLng ( <?php include("dbconnect.php"); $result = mysql_query("SELECT * FROM countries WHERE Country='{$_SESSION['Country']}'"); while($row = mysql_fetch_array($result)){ echo $row['Map']; } mysql_close($con); ?>); var myOptions = { zoom: 4, center: latlng, mapTypeId: google.maps.MapTypeId.ROADMAP }; var map = new google.maps.Map(document.getElementById("map_canvas"), myOptions); } </script> </head> <body onload="initialize()"> <div class="countryright" id="map_canvas"> include("dbconnect.php"); $snowball=explode(';',$_POST['syringa']); $turnsol=$snowball[1]; $violet =$snowball[2]; $wakerobin=$snowball[3]; global $turnsol; global $violet; global $wakerobin; echo '<center><b><big>' . $wakerobin. '</big></b></center><br /><br />'; $result=mysql_query("SELECT * FROM regions WHERE country='{$turnsol}' AND region='{$violet}' AND place='{$wakerobin}' AND sub !='' ORDER BY sub ASC"); while($row = mysql_fetch_array($result)){ $wheat="{$row['RegionPId']};{$turnsol};{$violet};{$wakerobin};{$row['sub']}"; $tigerlilly=$row['RegionPId']; echo '<input type="button" class="button3" name="place" id="place" value="' . $row['sub'] . '" onclick="loadSubPlace(\'getPlace.php\',\'txtHintPlaceSub\',\'hepatica=' . urlencode($wheat) . '\',\'getPlaceMap.php\',\'placemapcanvas\',\'Map=' . urlencode($tigerlilly) . '\');" />'; } echo '<input type="button" class="button3" name="addplace" id="addplace" value="Add Place" onclick="loadXMLDoc1(\'getAddPlaceSub.php\',\'txtHintPlaceSub\', encodeURI(\'addsubplace=' . $_POST['syringa'] . '\'));" />'; echo '<br /><br /><div id="txtHintPlaceSub"></div><br /><br />'; mysql_close($con); ?> I've cut out the script that doesn't relate to this so I hope I haven't missed anything important. IndyNS I am trying to create a dynamic form on my webpage. What I want to do is repeat this process multiple times on the same page. I know I have to have unique id's but I am not for sure how to set them. // JavaScript Document function addRowToTable(){ var tbl = document.getElementById('Division'); var lastRow = tbl.rows.length; // if there's no header row in the table, then iteration = lastRow + 1 var iteration = lastRow; // var iteration = lastRow + 1; var row = tbl.insertRow(lastRow); // cell 0 var cell0 = row.insertCell(0); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'Resource[]'; el.size = 30; cell0.appendChild(el); //cell 1 var cell1 = row.insertCell(1); var el = document.createElement("select"); cell1.innerHTML + '<option value="0">Avaliable</option>' + '<option value="1">Busy</option>' //cell 2 var cell2 = row.insertCell(2); var el = document.createElement('input'); el.type = 'text'; el.NAME = 'Comment[]'; el.size = 25; cell2.appendChild(el); } Problem: When I click the compute button, it does not do anything. It does not go to function CALCULATE and do its stuff . Please help me. This is my PHP code. Code: echo "<table border=1>"; while($row_contestant<$numrows_criteria) { $CId=mysql_result($result_contestants,$row_contestant,"CId"); $CName=mysql_result($result_contestants,$row_contestant,"CName"); echo "<tr><td width = '10'>$CId</td><td>$CName</td>"; for($start2 = 1;$start2 <= $counter;$start2++) { echo "<td><input type = 'text' name = 'cr[]' value = ''></td>"; } $row_contestant++; echo "<td><input type = 'text' name = 'rating' value = ''></td><td><input type = 'Button' name = 'getAvg' value = 'compute' onClick = calculate()></td></tr>"; } echo "</table> <p>"; } This is my Javascript calculate function code Code: function calculate() { sum = 0; for(i = 0;i<=Number(document.frmOne.counter.value);i++) { sum = sum + Number(document.frmOne.cr[i].value) } document.frmOne.rating.value = sum } The output: Any help would be highly appreciated. God Bless. hi every one i;m new here and i love to know programming languages and some friends adviced me to start with java script then php , and i guess i'm at the right place can you please tell how to start and where to begain i'm really don't know anything about programming
Im having a problem with my Android applet I am creating using a program called Eclipse It reads the error: 'The method onCreateOptionsMenu(Menu) in the type Activity is not applicable for the arguments (Menu)'. Here is what I have written: [code] public boolean onCreateOptionsMenu(Menu menu) { super.onCreateOptionsMenu(menu); MenuInflater awesome = getMenuInflater(); awesome.inflate(R.menu.main_menu, menu); return true; } [code] hi again, I want to say thank you for all of the help and I have the last assignment that she wants us to do and I had to pull up another assignment that she wanted us to build upon( which is one of those coding without anything advance) Code: <html> <head> <title> COMSC 100 Assignment 10 by Dennis McNeill [1190802] </title> <script> function getInputAsText(_id){return document.getElementById(_id).value} function getInputAsNumber(_id){return parseFloat(document.getElementById(_id).value)} function setOutput(_id, _value){document.getElementById(_id).value = _value} function calculate() { // declare all variables var variable1 var variable2 var variable3 var variable4 var variable5 // get variable's value = getInputAsNumber() = getInputAsNumber() // perform concatenation // write output value setOutput("resultAsText",resultAsNumber) } </script> </head> <body> Directions:<br> Type 5 numbers and click go<br> The highest of the 5 will appear<br> It is okay to use a decimal point<br> Input values:<br> First<input id="variable1"><br> Second<input id="variable2"><br> Third <input id="variable3"><br> Fourth<input id="variable4"><br> Fifth<input id="variable5"><br> <input type="submit" value="go" onclick="calculate()"> Output<br> Result #1:<input id= "myResult1" size="25"> </body> </html> now she wants us to do max <beta and then name the variables with if a<b and I don't know if I put that in the concatenation or what to name my variables! ugh. NOT ASKING TO DO MY HOMEWORK Hello all, I am having some trouble getting my Javascript code to work properly. I want to create a program that allows two objects to race to a certain point which is 1000px in my program. I have figured out how to get the images to race at random speed, and I have figured out a function to reset the program if the user chooses to restart. Basically I can't figure out how to get the clearTimeout() to stop the Race() function when it reaches 1000px. I am fairly new to the Javascript world and could really use some suggestions or a point in the right direction. Thanks in advance, AJ. Here is my program so far: <body> <script language="JavaScript" type="text/javascript"> <!-- function StartUp() { if ((car1.style.pixelLeft<1000) && (car2.style.pixelLeft<1000)) { Race(); } else { alert(); } } function Race() { car1.style.pixelLeft+=(Math.floor(Math.random()*11)); car2.style.pixelLeft+=(Math.floor(Math.random()*11)); stop=setTimeout("Race()",50); } function Restart() { clearTimeout(stop); car1.style.pixelLeft=10; car2.style.pixelLeft=10; } function swapImage() { var image = document.getElementById("imageToSwap"); var length = document.getElementById("Road"); image.src = Road.value; } //--> </script> <div id="car1" style="position:absolute; top: 10"> <img src="Car1.gif" alt=""/> </div> <div id="car2" style="position:absolute; top: 75"> <img src="Car2.gif" alt=""/> </div> <img id="imageToSwap" src="Road1000.gif" alt=""/> <form name="form1"> <br> <input type="button" value="Race" onClick="StartUp()"> <input type="button" value="Restart" onClick="Restart()"> <br> Track Length: <select id="Road" name="Road" onChange="swapImage()"> <option value="Road1000.gif">1000 feet</option> <option value="Road750.gif">750 feet</option> <option value="Road500.gif">500 feet</option> <option value="Road250.gif">250 feet</option> </select> </form> </body> Okay so if you go to this website: http://gameusd.com/ You can pick your game & country -- say its world of warcraft US And then you pick your realm and faction, and then it gives you the prices on those particular realms/factions. What i wanted to know was if it was possible to somehow make a program that fetches the prices of EVERY single realm/faction and lists them all side by side and in order of lowest to highest price or whatever. Would massively appreciate if somehow could tell me if its possible. Because obviously doing it all manually would be a huge pain in the *** and take hours. I'm new to programming in general and have had trouble deciding on a good starter project. I've decided to start with something that is (hopefully) pretty simple. I have about a dozen boxes full of vinyl records and would like to write a program to catalogue everything alphabetically by artist using prompts to ask for Album Title, Artist Title, and year. My question at this point is, is JavaScript a good way to do this? I have a fundamental knowledge of HTML, CSS, JavaScript and Ruby. I assumed JS would be the best way (that I know at this point) to do this project, but if I'm wrong, would love to hear it. What I don't understand at this point is how to output the information to a text file, or how to set up an interface to run the scripts. Any advice is very much appreciated. I'm currently using an automation software to automate a series of steps I perform on my computer. One of the tasks involves hundreds of If/Then loops, extracts text from websites using an embedded web browser, computes equations and write text files. The thing is, in order to share this with somebody else, they also need the same automation software installed, and then need to import it. So it's a process I'm trying to replace by creating a small program with a GUI that involves a simple installation on the user's PC (or ideally without installation). The language must be flexible enough to perform the same actions that I listed above - and more preferably. I'm a complete novice with anything besides HTML/CSS so I'm looking for A flexible programming language that isn't rocket science to learn from scratch and is ideal for small stand-alone programs The ability to create a GUI. I'd be happy to read any good reference you have about the language/design knowledge needed for GUI's. Thanks in advance Hi so i am using onClick="myPopup(); on a button and when someone clicks on the button, it pops up an advertisement in a new tab. But is there a way to make the users stay on the page where the button is located instead of forcing the browser to automatically switch to the advertisement tab when a button is clicked? Greeting Everyone, Can anyone breakdown the differences between programming languages in VERY VERY BASIC plain English? (i.e. HTML use for website format, CSS used for the graphics on the webpage) Here's what I have questions about: 1. Differences between the most commonly used programming languages for software/web development (Javascript, Ruby on Rails, Phyton, etc.). 2. How do you determine which programming languages to use? 3. What factors are considered? Thank in advance for the people that reply. =) I have searched all over for tutorials on multiplayer game programming. I cannot seem to find anything relevant to my question, though. I don't even think that I can use javascript, but as I said, I do not know where to start. All I want, for now, is to make something simple like tic-tac-toe or rock-paper-scissors, which will be played by two users on two machines. Then once I've gotten that, I can move onto making something more in depth. Any push in the right direction is greatly appreciated! -Shane |