Changing hidden field if any checkbox is checked
I've obviously got something wrong here. How do I pass a "interestsYes" or "interestsNo" to a hidden field based on whether any of eight checkboxes are checked? Here's what I have, which basically says, "If any checkbox is checked, set the hidden field "interestAny" to "Yes". If no checkboxes are checked, set the hidden field "interestAny" to "No".
- $(document).ready(function() {
- if ($("#clientForm input:clientInterest:checked").length > 0)
- {
- $('#interestAny').val($(this).val('Yes'));
- } else {
- $('#interestAny').val($(this).val('No'));
- }
- });
- In the form we have this hidden field:
- <input type="hidden" name="interestAny" value="">