Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-07-2009, 10:21 PM   PM User | #1
usurper
New to the CF scene

 
Join Date: Jan 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
usurper is an unknown quantity at this point
How to filter jquery results from google spreadsheets

This is a bit of a noob question.

I'm trying to query some data from google spreadsheets using javascript.

This is the URL request

Code:
var url = 'http://spreadsheets.google.com/feeds/list'
                         + '/' + param_ssKey + '/' + param_wsId + '/public/values' +
                        '?sq=category%3DselectedSearch&alt=json-in-script&callback=cm_loadMapJSON';
The problem is that 'selectedSearch' in the the above code (sq=category%3DselectedSearch) is a variable name and not a literal. The expression is expecting a literal. Is there some syntax that I need to apply to the selectedSearch variable to make this query work possible?

thanks
usurper is offline   Reply With Quote
Old 01-08-2009, 03:26 PM   PM User | #2
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,468
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
as far as javascript is concerned, category%3DselectedSearch is just a string primitive in the code.

you will need to know what param_ssKey and param_wsId are.

you can type those into firebug from the original page, and it will tell you the actual value of those variables.
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Old 01-08-2009, 03:40 PM   PM User | #3
usurper
New to the CF scene

 
Join Date: Jan 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
usurper is an unknown quantity at this point
Quote:
Originally Posted by rnd me View Post
as far as javascript is concerned, category%3DselectedSearch is just a string primitive in the code.

you will need to know what param_ssKey and param_wsId are.

you can type those into firebug from the original page, and it will tell you the actual value of those variables.
Thanks. I don't think I explained it well. For example.. if I change the query to include category%3DRestaurants, it works fine. It returns all the records with the value 'Restaurants' in the category column. So there is no issue with the param variables.

What I would like to be able to do is use a variable(selectedSearch) in the place of 'Restaurants'.

The variable would contain a string literal that I retrieve from a form.

I.E. the user selects 'Restaurants' from a dropdown box. This value gets assigned to the variable selectedSearch and this in turn gets added to the sq expression.

thanks
usurper is offline   Reply With Quote
Old 01-08-2009, 06:10 PM   PM User | #4
rnd me
Senior Coder

 
rnd me's Avatar
 
Join Date: Jun 2007
Location: Urbana
Posts: 3,468
Thanks: 9
Thanked 466 Times in 450 Posts
rnd me is a jewel in the roughrnd me is a jewel in the roughrnd me is a jewel in the rough
if str was a string you got from a form:

"category%3DRestaurants" could be replaced by "category%3D"+encodeURIComponent(str);
__________________
my site (updated 5/13)
STATS (2013/5) HTML5:90.2% MOB:14% IE7:0.5% IE8:8.6% IE9:9.8% IE10:10%
rnd me is offline   Reply With Quote
Users who have thanked rnd me for this post:
usurper (01-08-2009)
Old 01-08-2009, 10:41 PM   PM User | #5
usurper
New to the CF scene

 
Join Date: Jan 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
usurper is an unknown quantity at this point
Thanks again.

I've tried this

Code:
'?sq=category%3D'+encodeURIComponent(selectedSearch)+&alt=json-in-script&callback=cm_loadMapJSON';
and this

Code:
'?sq="category%3D"+encodeURIComponent(selectedSearch)&alt=json-in-script&callback=cm_loadMapJSON';
still not working though. Can you spot anything? I've checked if selectedSearch is holding the right value
usurper is offline   Reply With Quote
Old 01-08-2009, 10:51 PM   PM User | #6
usurper
New to the CF scene

 
Join Date: Jan 2009
Posts: 4
Thanks: 1
Thanked 0 Times in 0 Posts
usurper is an unknown quantity at this point
got it

thanks a lot

Code:
'?sq=category%3D'+encodeURIComponent(selectedSearch)+'&alt=json-in-script&callback=cm_loadMapJSON';
usurper is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:22 PM.


Advertisement
Log in to turn off these ads.