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