I need help with this loop through an array. Right now I have 3 dropdown menus. I am trying to loop through my array and say if a value from a drop down menu matches a value in the array then run a function (that plots markers on my map). It all works.
EXCEPT, All 3 dropdown menus have to match a value currently, How can I say if one value matches and the rest are null plot all those locations? Does that make sense? I need to account for 1 or 2 or even 3 drop down menus not being selected. Let me know if you need to see more code.
for (var i = 0; i <mymarkers.length; i++) {
if (mymarkers[i].type==type&&mymarkers[i].day==day&&mymarkers[i].time==time){
mymarkers[i].setMap(MYMAP.map);
}else{
mymarkers[i].setMap(null);
}
}
This might not be specifically a map problem, but it is a problem that is related to my finishing a location map. Here is a link: http://mycwebdesign.com/meetings.php. If you select “MA” and “Friday” and “Late” you will see it work.
What you want for any marker with properties is for its properties to match the selected property (
truewill put it on the map) OR for the selected property to be--, so that test is alsotrue.If
type=='--'then it doesn’t matter whatmymarkers[i].typeis: that test will betrue.You will probably need the three lines of code above to be all on one line. It’s easier to see what’s going on here with it split up.