Need Help with Array and file setup, should be easy!!

Discussion in 'JavaScript' started by id4382, Feb 4, 2008.

  1. #1
    Hello! I need help on how to create a var array for a list of about 500 cities. I am going to use this list in a geoIP variable to hide some text. I need the code to tell the if statement to look in the file 'cities.js', and if the city returned by the geoIP if statement equals a city in the list, then I need it to perform the function I have assigned.


    Here is the code snippet, I need the list of cities to replace the 'stockton', without just typing them all out in the html file:



    Here is my array:
    Anyone's help would be much appreciated!!!

     
    id4382, Feb 4, 2008 IP
  2. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #2
    try to check it in loop:
    
    for (var i=0; i < cityArray.length; i++) {
    if (geoip_city() == cityArray[i]){ 
    HideText();
    }
    }
    
    Code (markup):
     
    locdev, Feb 5, 2008 IP
  3. id4382

    id4382 Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Well, after inputing the code, the if and function statements did not work. I have the array in a seperate file on my server. I even pasted the entire array code into the .htm file, and it still did not respond.

    Here is the code snippet with external file:



    Not sure if there is still something wrong. Suggestions?
     
    id4382, Feb 5, 2008 IP
  4. locdev

    locdev Active Member

    Messages:
    171
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    58
    #4
    can you create a test page so we can see the error ?
     
    locdev, Feb 5, 2008 IP
    id4382 likes this.
  5. id4382

    id4382 Peon

    Messages:
    29
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Actually, I found out what was wrong, I had an extra "}" and it was throwing the code out, and excluding the function code. Thanks for your help!!
     
    id4382, Feb 5, 2008 IP