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 8062617
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:43:50+00:00 2026-06-05T10:43:50+00:00

I have two arrays: one for article names, and the other for url links

  • 0

I have two arrays: one for article names, and the other for url links to each article. I am trying to populate a dropdown list within an infowindow with the article names, linking to each article when selected.

It seems as if the links may have to do with using the onchange event, and otherwise I am using the "domready" eventListener to access the <select> elements’ id tag.

Here is the relevant code I have so far, which is not working:

function setDropDownList(mapMarker, names, links)
{
    // event listener for dropdown list in the map markers' infowindow
    google.maps.event.addListener(mapMarker, "domready", function()
    {
        var articles = document.getElementById("select");

        var nextArticle, nextOption;

        for(var i = 0; i < names.length; i++)
        {
            nextArticle = names[i];
            nextOption = new Option(nextArticle);

            /* add the new option to the option list
             ("null" for IE5, "-1" for all other browsers) */
            try
            {
                articles.add(nextOption, -1);
            }
            catch(e)
            {
                articles.add(nextOption, null);
            }
        }
    });
} // end of function setDropDownList
  • 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-05T10:43:51+00:00Added an answer on June 5, 2026 at 10:43 am

    Since I am calling the setDropDownList function after the marker is placed, I removed that listener and added one to display the infowindow when the marker is clicked.

    DEMO http://jsfiddle.net/yV6xv/10/

    It’s up to you how to handle the onchange event when a selection is made. Right now, it alerts with a message and a dummy link.

    function setDropDownList(mapMarker, mapInfoWindow, names, links)
    {
    
            var articles = document.getElementById("select");
            articles.onchange = function() {
              alert("Going to link " + links[this.options.selectedIndex]);
            };
            var nextArticle, nextOption;
    
            for(var i = 0; i < names.length; i++)
            {
                nextArticle = names[i];
                nextOption = new Option(nextArticle);
    
                /* add the new option to the option list
                 ("null" for IE5, "-1" for all other browsers) */
                try
                {
                    articles.add(nextOption, -1);
                }
                catch(e)
                {
                    articles.add(nextOption, null);
                }
                mapInfoWindow.setContent(document.getElementById("select"));
    
                google.maps.event.addListener(mapMarker, 'click', function() {
                  mapInfoWindow.open(map, this);
                });
        }
    } // end of function setDropDownList
    

    I should add that map is global.

      var map;
      var mapOptions = { center: new google.maps.LatLng(0.0, 0.0), zoom: 2,
        mapTypeId: google.maps.MapTypeId.ROADMAP };
    
      function initialize() {
        map = new google.maps.Map(document.getElementById("map_canvas"), mapOptions);
        var mymarker = new google.maps.Marker({
          map:map,
          position:new google.maps.LatLng(0,0)
        });
    
        var mynames = ["-- Choose an article --", "How to Launch a Fireball", "The Trinity of Magic", "Defending Against the Hax"];
    var mylinks = ["to current page itself #", "http://fireball", "http://trinity", "http://hax"];
    
        var myinfowindow = new google.maps.InfoWindow();
        setDropDownList(mymarker, myinfowindow, mynames, mylinks);
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have two arrays where one is a permutation of the other: A
I have two arrays, one is very large (more than million entries) and other
I have two arrays of data that I'm trying to amalgamate. One contains actual
I have two different arrays. One array, a, for a list of people. My
I have two cell arrays one called info{} and the other is called data{}
Let's say I have two arrays: one is the regex and the other one
I have two arrays. One for input boxes and other for checkbox. inputbox[] checkbox[]
i have two arrays (actually one, but i created two for each columns). I
I have two arrays one is for names and another is for phone numbers,and
using Crystal XI I have two arrays - one captures a list of timepoints

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.