catonthecouchproductions
asked on
Hide/show - view checkboxes to <a> links
Hey,
I have a Google Map section on my site with 3 categories:
- Alpine
- Nordic
- Tubing
Right now they all have say 10 markers for each category. And are currently can be hide/show via a checkbox. I am looking to move it to something like:
Another developer coded this section for the checkboxes:
And lastly, the output of the checkboxs looks something like:
What would be the best way do this using <a> not the checkboxes?
Thanks!
Ryan
I have a Google Map section on my site with 3 categories:
- Alpine
- Nordic
- Tubing
Right now they all have say 10 markers for each category. And are currently can be hide/show via a checkbox. I am looking to move it to something like:
<div class="marker_legend">
<ul>
<li><a href="#alpine"><span><img width="12" height="20" style="margin-bottom:-6px;" alt="" src="http://localhost:8888/ski/wp-content/themes/images/googlepins/blue_Marker.png"> Alpine</span></a></li>
<li><a href="#nordic"><span><img width="12" height="20" style="margin-bottom:-6px;" alt="" src="http://localhost:8888/ski/wp-content/themes/images/googlepins/red_Marker.png"> Nordic</span></a></li>
<li><a href="#tubing"><span><img width="12" height="20" style="margin-bottom:-6px;" alt="" src="http://localhost:8888/ski/wp-content/themes/images/googlepins/green_Marker.png"> Tubing</span></a></li>
</ul>
</div>
Another developer coded this section for the checkboxes:
function hideOrShowPins(whoToShow,whichBox){
for (i=0;i<markers.length;i++ ){
if(markers[i][1]==whoToShow && whichBox.checked == false){
markers[i][0].hide();
}else if(markers[i][1]==whoToShow){
markers[i][0].show();
}
}
}
And lastly, the output of the checkboxs looks something like:
<input type="checkbox" onclick="hideOrShowPins('alpine',this);" checked="checked" value="alp" name="al">
What would be the best way do this using <a> not the checkboxes?
Thanks!
Ryan
ASKER
I tried that, thought it would be that simple :)
The code is checking for checked true/false. Guessing that is why its not firing?
The code is checking for checked true/false. Guessing that is why its not firing?
function hideOrShowPins(whoToShow,whichBox){
for (i=0;i<markers.length;i++ ){
if(markers[i][1]==whoToShow && whichBox.checked == false){
markers[i][0].hide();
}else if(markers[i][1]==whoToShow){
markers[i][0].show();
}
}
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hey, no go on that. The only limitation is the output of that is from the google map API. A marker looks like:
I also tried that code on a onclick event
<img style="width: 20px; height: 34px; -moz-user-select: none; border: 0px none; padding: 0px; margin: 0px; position: absolute; left: 295px; top: 220px; z-index: -144372608; cursor: pointer;" src="http://localhost:8888/ski/wp-content/themes/ski-maine/images/googlepins/blue_MarkerA.png" id="mtgt_unnamed_0">
I also tried that code on a onclick event
ASKER
Here is an example of how it works now: http://goo.gl/srIOP - at the bottom right are the checkboxes. That same behavior but im trying to get the toggle on the link instead.
i have only changed the if condition, it should not matter where the marker output is coming from.
What is the output of my code
What is the output of my code
ASKER
This is what I have for my <a>
<li><a href="javascript:hideOrShowPins('alpine',this);" id="al" name="al"><span><img src="<?php bloginfo( 'template_url' ); ?>/images/googlepins/blue_Marker.png" alt="" width="12" height="20" style="margin-bottom:-6px;"/> Alpine</span></a></li>
Not sure how above code matters.
In that hideOrShowPins(), where is the marker array taken from? what are its values?
In that hideOrShowPins(), where is the marker array taken from? what are its values?
ASKER
Looking through it again, I think i would be better usability wise and code to attach it to the code you worked on before: http://jsfiddle.net/nhDxH/7/
So say you click Alpine (in the accordion) you would see ONLY the Alpine markers. If you click the Nordic header in the accordion you'll only see the Nordic markers.
The checkbox code to fire that function posted in my question at the top looks like:
So say you click Alpine (in the accordion) you would see ONLY the Alpine markers. If you click the Nordic header in the accordion you'll only see the Nordic markers.
The checkbox code to fire that function posted in my question at the top looks like:
<div id="toggle_markers">
<div class="alp">
<input name="al" type="checkbox" value="alp" checked="checked" onclick="hideOrShowPins('alpine',this);"/> Alpine
</div>
<div class="alp">
<input name="no" type="checkbox" value="no" checked="checked" onclick="hideOrShowPins('nordic',this);" />
Nordic
</div>
<div class="alp">
<input name="tu" type="checkbox" value="tu" checked="checked" onclick="hideOrShowPins('tubing',this);" />
Tubing
</div>
</div>
ASKER
That said we can find out HOW it is getting ALL alpine markers and $(XXX).hide(); to hide them all.
<a href="javascript:hideOrSho