I am terribly stuck with Contact form 7 and this is my first post here so please be kind!
I think the answers in here and here are really close, but me not being a jquery guru... doesn't help.
Okay my issue is that I need to display a div if 2 of 3 specific check boxes are checked and display another if another combination of 3 is checked.
So... Checkbox 1 Sydney Checkbox 2 Melbourne
Checkbox 3 GL Collection
So if collection is checked and one of the other exclusive checkboxes are checked above it, they will display different boxes.
Here is the cut down version of the html output of CF7
<div class="melbpop">
<span class="wpcf7-form-control-wrap boutique">
<span class="wpcf7-form-control wpcf7-checkbox wpcf7-exclusive-checkbox">
<span class="wpcf7-list-item first last">
<input type="checkbox" value="Melbourne" name="boutique">
<span class="wpcf7-list-item-label">Melbourne</span>
</span>
</span>
</span>
<div class="melbournebox hideit"></div>
</div>
<div class="glcheckbox">
<span class="wpcf7-form-control-wrap checkbox-gl">
<span class="wpcf7-form-control wpcf7-checkbox checkbox">
<span class="wpcf7-list-item first last">
<input type="checkbox" value="GL" name="checkbox-gl[]">
<span class="wpcf7-list-item-label">GL</span>
</span>
</span>
</span>
</div>
<div class="glmelb hideit">INFO HERE</div>
<div class="glsyd hideit">INFO HERE</div>
As I am using CF7, I cannot add a class specifically to the input iself, but wrap a div or span with a class.
I apologise for my bad js coding...
<script type="text/javascript">
jQuery(function() {
jQuery('.melbpop').click(function() {
if (jQuery(':checked', this).length > 0) && (jQuery(':checked', '.glcheckbox').length > 0)){
jQuery('.glmelb').addClass('showit');
jQuery('.glmelb').removeClass('hideit');
} else {
jQuery('.glmelb').addClass('hideit');
jQuery('.glmelb').removeClass('showit'); }
});
});
</script>
Originally in my testing, I had one checkbox working but could not work out how to target 2 checkboxes...
I think I know what is wrong with the code... no... probably not...
ANY guidance would be appreciated...
Felixius
Aucun commentaire:
Enregistrer un commentaire