0

I want to integrate a link with an onclick event to a function like <a href="#" onclick="fireMarker(1);">Map Marker URL 1</a> and <a href="#" onclick="fireMarker(2);">Map Marker URL 2</a> into a jump menu like

<select id="selectbox" name="" onchange="javascript:location.href = this.value;">
    <option value="https://www.yahoo.com/" selected>Option1</option>
    <option value="https://www.google.co.in/">Option2</option>
    <option value="https://www.gmail.com/">Option3</option>

</select>

OR

<select onchange="fireMarker(this);">
    <option value="15">1</option>
    <option value="16">2</option>
    <option value="18">3</option>
</select>

The fireMarker function is:

 function fireMarker(id){
                    google.maps.event.trigger(markers[id], 'click');
                    markers[id].setAnimation(google.maps.Animation.DROP);
                    markers[id].setVisible(true);
                    }

When I click an option I want it to execute urls in the format Map Marker URL. I hope to have multiple jump menus on same page Thanks

User301276
  • 55
  • 1
  • 8
  • 1
    taste this: https://stackoverflow.com/questions/3487263/how-to-use-onclick-or-onselect-on-option-tag-in-a-jsp-page/16432178 – Malama Nov 18 '21 at 13:19

1 Answers1

0

Replace onchange="fireMarker(this); with onchange="fireMarker(value)"

like:

<html>
<head>  
<script type="text/javascript">
    function fireMarker(id) {
        google.maps.event.trigger(markers[id], 'click');
        markers[id].setAnimation(google.maps.Animation.DROP);
        markers[id].setVisible(true);
   }
</script>
</head>
<body>
    <select onchange="fireMarker(value)">
        <option value="15">1</option>
        <option value="16">2</option>
        <option value="18">3</option>
    </select>
</body>
Chinmay Dey
  • 134
  • 4