SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    add group values to drop down menu

    Hello, I have a drop down menu that is populated by the following javascript:
    Code:
    // Place holder
    var AS_Airport = 
        {
        group :
            "Heathrow Airport",
    
        premise:
            "Flight Number (eg VS401 Dubai)",
    
        shortcuts :
            [           
                ["HEATHROW TERMINAL 1", "Heathrow Airport Terminal 1"],
    	    ["HEATHROW TERMINAL 3", "Heathrow Airport Terminal 3"],
    	    ["HEATHROW TERMINAL 4", "Heathrow Airport Terminal 4"],
    	    ["HEATHROW TERMINAL 5", "Heathrow Airport Terminal 5"]
            ]
    
    
    
    	};
    
    var AddressShortcuts = [AS_Airport];
    The drop down category is Heathrow Airport. When that is selected another drop loads the shortcuts (Terminal 1, Terminal 3 etc).

    what i would like to do is add another selection with another set of shortcuts to the above but am unsure how to do it.

    for example i have tried the following without success:


    Code:
    // Place holder
    var AS_Airport = 
        {
        group :
            "Heathrow Airport",
    
        premise:
            "Flight Number (eg VS401 Dubai)",
    
        shortcuts :
            [           
                ["HEATHROW TERMINAL 1", "Heathrow Airport Terminal 1"],
    	    ["HEATHROW TERMINAL 3", "Heathrow Airport Terminal 3"],
    	    ["HEATHROW TERMINAL 4", "Heathrow Airport Terminal 4"],
    	    ["HEATHROW TERMINAL 5", "Heathrow Airport Terminal 5"]
            ]
    
    
    group :
            "Heathrow Hotels",
    
        premise:
            "Room Number",
    
        shortcuts :
            [           
                ["EDWARDIAN LHR", "Heathrow Raddisson Edwardian Hotel"],
    	    ["SOFITEL LHR", "Sofitel Hotel, Heathrow Terminal 5"]
            ]
    
    
    	};
    
    var AddressShortcuts = [AS_Airport];
    when i use the code above to try and add another group and set of values it doesn't add any of the groups. if someone could please let me know the correct way to add a group to the above i think it will work fine.

    thanks

  2. #2
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    I wonder if it's to do with you having two names (group) with different values (one is airport and one is hotels).

    Code:
    var AS = {
       Airports : {
         group :
            "Heathrow Airport",
    
          premise:
            "Flight Number (eg VS401 Dubai)",
    
          shortcuts :
            [           
                ["HEATHROW TERMINAL 1", "Heathrow Airport Terminal 1"],
    	    ["HEATHROW TERMINAL 3", "Heathrow Airport Terminal 3"],
    	    ["HEATHROW TERMINAL 4", "Heathrow Airport Terminal 4"],
    	    ["HEATHROW TERMINAL 5", "Heathrow Airport Terminal 5"]
            ]
         },
    
      Hotels : {
        group :
            "Heathrow Hotels",
    
          premise:
            "Room Number",
    
          shortcuts :
            [           
                ["EDWARDIAN LHR", "Heathrow Raddisson Edwardian Hotel"],
    	    ["SOFITEL LHR", "Sofitel Hotel, Heathrow Terminal 5"]
            ]
          }
    };
    I don't know that this is correct syntax (likely isn't), but you want to add more name-value pairs using the same names, so I figured you need them differentiated somehow (by something other than order). So now I've attempted two groups: Airports and Hotels. Each has their own group, premise and shortcuts.

    I suppose I could check my syntax by reasing the JSON pages, but I'm about to go get tasty tasty foods (lunchtime).

  3. #3
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi thanks for the reply. using the code you gave me the main drop down menu still does not display either 'Heathrow Airport' or 'Heathrow Hotel' as a main option.

    i should also mention that code is not causing any errors in the form (ie with an extra ' or . it is working fine but just not showing the above.

    thanks

  4. #4
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    any more suggestions on this?

  5. #5
    SitePoint Wizard Stomme poes's Avatar
    Join Date
    Aug 2007
    Location
    Netherlands
    Posts
    10,283
    Mentioned
    51 Post(s)
    Tagged
    2 Thread(s)
    Sorry, I wish my JS were better... hopefully a guru will show up.

    Possibly someone will ask you what your actual script itself is, and what the HTML is that it's interacting with (your form).

  6. #6
    SitePoint Evangelist
    Join Date
    Feb 2005
    Location
    London, UK
    Posts
    422
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think that is the next step. if i can get a piece of code that theoretically should work i can test it. if the code doesnt work then there is probably more to it then i think and i will upload the rest of the code.


Bookmarks

Posting Permissions

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