Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,349
    Thanks
    11
    Thanked 589 Times in 570 Posts
    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 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • #3
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,349
    Thanks
    11
    Thanked 589 Times in 570 Posts
    if str was a string you got from a form:

    "category%3DRestaurants" could be replaced by "category%3D"+encodeURIComponent(str);
    my site (updated 13/9/26)
    BROWSER STATS [% share] (2014/5/28) IE7:0.1, IE8:5.3, IE11:8.4, IE9:3.2, IE10:3.2, FF:18.2, CH:46, SF:7.9, NON-MOUSE:32%

  • Users who have thanked rnd me for this post:

    usurper (01-08-2009)

  • #5
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    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

  • #6
    New to the CF scene
    Join Date
    Jan 2009
    Posts
    4
    Thanks
    1
    Thanked 0 Times in 0 Posts
    got it

    thanks a lot

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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •