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. #2
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 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.
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  3. #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. #4
    Senior Coder rnd me's Avatar
    Join Date
    Jun 2007
    Location
    Urbana
    Posts
    4,650
    Thanks
    11
    Thanked 626 Times in 605 Posts
    if str was a string you got from a form:

    "category%3DRestaurants" could be replaced by "category%3D"+encodeURIComponent(str);
    Create, Share, and Debug HTML pages and snippets with a cool new web app I helped create: pagedemos.com

  5. Users who have thanked rnd me for this post:

    usurper (01-08-2009)

  6. #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

  7. #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
  •