Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8893759
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T23:19:38+00:00 2026-06-14T23:19:38+00:00

I am new to this but I have tried to put some code together,

  • 0

I am new to this but I have tried to put some code together, however I’m getting errors flagging up and it doesn’t seem to work. I would like some input to help debug it.

I have a cookie called “country” saved with a value of “AZ”. I want to pull this cookie using javascript and store it as a variable, then use it in my google map page. This is the code I have:

// Setup variable with blank value
var country_code ='';
// Use read_cookie function to pull "country" value from cookie
if (country_code) var country_code = read_cookie('country');
// Make sure its value is lower case (required)
country_code = country_code.toLowerCase();

And then a bit further down:

var input = document.getElementById('loc');
var options = { types: [], ComponentRestrictions({ 'country': country_code });};
var autocomplete = new google.maps.places.Autocomplete(input, options); 

The first error is that I have too many brackets on the “componentrestriction” line. How should this be done? It looks like I am closing them correctly, I encase the componentrestrictions with ({}); and var options with {};

EDIT: This is the read cookie function code I found on stackoverflow:

// Reading Cookie V0.1
function read_cookie(key){
    var result;
    return (result = new RegExp('(?:^|; )' + encodeURIComponent(key) + '=([^;]*)').exec(document.cookie)) ? (result[1]) : null;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T23:19:39+00:00Added an answer on June 14, 2026 at 11:19 pm

    You have a semicolon inside the statement and to much brackets after ComponentRestrictions.

    Write it this way:

    var options = { 
           types: [], 
           ComponentRestrictions: { 
                              'country': country_code 
                                  }
                  };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am new to mysql but have recently tried doing some tutorials to advance
I'm very new to C, but have no idea why this program breaks. The
I am new to Emacs. I have googled this but no good answer there.
I am pretty new to this iPhone dev thing but so far I have
i have defined a receiver for NEW_OUTGOING_CALL broadcast. But this is not getting invoked.
I think this is mostly because I'm new to PHP OOP, but I have
I have this: var blockRegEx = new Regex((proc sql;)(.*?)(quit;), RegexOptions.IgnoreCase | RegexOptions.Multiline); but it
I have a database connection that I got like this: db = Mongo::Connection.new.db(app-development) but
This should be pretty simple, but I am new at LINQ. I have a
I have plenty of experience with this in PHP, but am fairly new to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.