Hey,
Thank you for your time. The issue I have is based on a jquery function which serves 2 purposes based on 2 sets of checkboxes. The first set is a membership plan the customer chooses (3 checkboxes - 3 month plan/6 month/12 months).
The first conditional you see looks for an attribute 'data-val'. Problem is, it's based on an old version of a website that loads checkboxes dynamically and I have no idea where I would assign this 'data-val' to the set of checkboxes below so I can properly determine how many months are assigned to their selection. The reason we use this code is because the customer chooses a membership and then the months they prefer to use for their membership. So if you choose 3 month membership, you will then choose 3 months out of 12 (each with a checkbox) and this function determines if you properly selected the correct number of months for your membership.
When I use this code, with the checkboxes we generate in the new version of the site, nothing happens. No errors - just nothing. Because there is no data-val attribute. How do I overcome this so the 2nd conditional knows how many months were selected in the membership checkboxes? The checkboxes for the membership are below.
Below are the checkboxes. If the first conditoinal is looking for 'data-val' attribute, WHERE would I put them? Inside the checkbox code? (I generate these dynamically but I can control the values/names/attributes if I have to).Code:function checkMonth(){ var Month = null; jQuery('#2').find('input').each(function(){ if (jQuery(this).attr('checked')){ Month = jQuery(this).attr('data-val'); // not data-val } }) var count = 0; if (Month!=null && Month !=undefined){ jQuery('#1').find('input').each(function(){ if (jQuery(this).attr('checked')){ count=count+1; } }) if (count!=parseInt(Month)){ alert('Please check the correct number of months'); return false; } } return true; }
Thank you for your time.Code:<div class="input-box-2" id="2"> <ul id="options-2-list" class="options-list"> <li><input type="checkbox" class="checkbox validate-one-required-by-name product-custom-option" onclick="opConfig.reloadPrice()" name="options[2][]" id="options_2_2" value="13" price="479.99" /><span class="label"><label for="options_2_2">12 Months <span class="price-notice">+<span class="price">$479.99</span></span></label></span> <script type="text/javascript">$('options_2_2').advaiceContainer = 'options-2-container';$('options_2_2').callbackFunction = 'validateOptionsCallback';</script></li> <li><input type="checkbox" class="checkbox validate-one-required-by-name product-custom-option" onclick="opConfig.reloadPrice()" name="options[2][]" id="options_2_3" value="14" price="239.99" /><span class="label"><label for="options_2_3">6 Months <span class="price-notice">+<span class="price">$239.99</span></span></label></span><script type="text/javascript">$('options_2_3').advaiceContainer = 'options-2-container';$('options_2_3').callbackFunction = 'validateOptionsCallback';</script></li> <li><input type="checkbox" class="checkbox validate-one-required-by-name product-custom-option" onclick="opConfig.reloadPrice()" name="options[2][]" id="options_2_4" value="15" price="119.99" /><span class="label"><label for="options_2_4">3 Months <span class="price-notice">+<span class="price">$119.99</span></span></label></span><script type="text/javascript">$('options_2_4').advaiceContainer = 'options-2-container';$('options_2_4').callbackFunction = 'validateOptionsCallback';</script></li></ul>



Reply With Quote
Bookmarks