nano Posted October 21, 2010 Share Posted October 21, 2010 Hey Guys, I am a little stuck at the moment. I have the following HTML: <tr> <td class="place">Cardiff</td> <td class="selection"><input type="checkbox" name="Cardiff" class="been" value="CA_1" /></td> <td class="selection"><input type="checkbox" name="Cardiff" class="going" value="CA_2" /></td> </tr> <tr> <td class="place">Amsterdam</td> <td class="selection"><input type="checkbox" name="Amsterdam" class="been" value="AM_1" /></td> <td class="selection"><input type="checkbox" name="Amsterdam" class="going" value="AM_2" /></td> </tr> I am playing with Google Maps API and need to show different marker dependent on what the user checks. If they select the input with class been - show marker1.png If they select the input with class going - show marker2.png Then the fun one which I need help with.. If they select both checkboxes in the same table row, then show marker3.png This is what I currently have: $('tr input[type="checkbox"]').click(function() { var noCheckboxes = $('input[type=checkbox]'); var selected = this.value; var boxClass = $(this).attr("class"); var location = selected.substring(0, selected.indexOf('_')); // example: CA var boxType = boxClass.substring(0, boxClass.indexOf(' ')); // been or going due to focus // Find out if multiple checkboxes are checked for single marker if(noCheckboxes.filter(':checked').length > 1 && noCheckboxes.filter(':checked').attr('value', selected).length > 1) { plotImage = 'marker3.png'; } else { // Set plotImage dependant on checkbox checked switch (boxType) { case 'been': plotImage = 'marker1.png'; break; case 'going': plotImage = 'marker2.png'; break; default: plotImage = 'marker1.png'; } } }); Sooo basically, how can I give the markers a different image if both the check boxes are checked and in the same row only. My above jQuery fails badly Any help would be appreciated. Cheers. Quote Link to comment https://forums.phpfreaks.com/topic/216475-jquery-check-two-boxes-are-checked/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.