Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Well, nobody responded, but after a few days I solved my own problem. Basically the loop structure I came up with <em>was</em> correct. But there were a few missing pieces.</p> <p>I added break statements to a couple of the if statements. Because each marker could have several values for a given category, it might loop through once and find a match and set the "surfaceMatches" flag to true. But then it would loop through again and check the next value in the category, find it wasn't a match, and set the flag to false. So putting in the break caused the for loop to stop after a category match.</p> <p>Also, at the end I had gmarkers[i].show(); . It should have been gmarkers[k].show().</p> <p>And lastly, I realized that when I set up my "category OK" flags, I set them all to false. This was okay, except that what if the user left a particular category blank? Then the matching loops would never be executed, and the flags would remain false. So I added some statements to check if a category didn't have any values checked, then set the OK flag to true, like this:</p> <p>if (surfaceChecked.length &lt; 1) { surfaceOK = true; }</p> <p>If you want to see the code in action, go here: <a href="http://www.joshrenaud.com/pd/trails_withcheckboxes5.html" rel="nofollow">http://www.joshrenaud.com/pd/trails_withcheckboxes5.html</a></p> <p>Probably nobody cares about any of that. But this might be helpful:</p> <p>As a javascript novice, I did come across a debugging tool that made all the difference for me and helped me find my mistakes: www.webmonkey.com/2010/02/javascript_debugging_for_beginners/</p> <p>Using those log(); statements was VERY handy, although the output got pretty long with all the nested loops in my javascript.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload