Getting value of a cell from google docs spreadsheet into javascript
google-docs, google-sheets, javascript
Solution
First of all, what i would recommend is to "Get a link to Published Data" as csv, as it is just 1 field so you don't have to parse it. If made this spreadsheet, and make a link with "Get a link to Published Data", this second link will get a csv with just one field in this case. You will be able to get this with the following js code (note i'm using jQuery)
$.ajax("https://docs.google.com/spreadsheet/pub?key=0Auwt3KepmdoudE1iZFVFYmlQclcxbW85YzNZSTYyUHc&single=true&gid=0&range=b5&output=csv").done(function(result){
alert(result);
});
Regards
EDIT: The full code
<!doctype>
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"> </script>
</head>
<body>
<script>
$.ajax("https://docs.google.com/spreadsheet/pub?key=0Auwt3KepmdoudE1iZFVFYmlQclcxbW85YzNZSTYyUHc&single=true&gid=0&range=b5&output=csv").done(function(result){
alert(result);
});
</script>
</body>
</html>
Problem
I have a javascript function ``` function calculate() { var interestRate=4.5; ... } ``` I would like the interestRate to come from a cell in a google Docs spreadsheet. I created a google docs spreadsheet, and stored the interest rate in Cell B2 I used the "Get a link to Published Data" feature in Google Docs to to get a link to cell B2. The link looks like this. https://docs.google.com/spreadsheet/pub?key=....c&single=true&gid=0&range=b2&output=html Is there anyway of getting the value from the link into my javascript function? Thanks