I'm trying to set this the way if "marketingAAA" is checked as true, a hidden checkbox "marketingPhone" is set as TRUE as well. This works.
However, if any other checkbox on the page is set to be TRUE, then it still goes TRUE for "marketingPhone". Can't figure this out why. It should stay as FALSE if "marketingAAA" is not checked TRUE. Does anyone see the issue?
<script>
$(function() {
var marketingAAA= $("input[type='checkbox']");
var marketingPhone = $("input[type='hidden'][name='marketingPhone']");
marketingAAA.on('change', function()
{
if ($(this).val() == "TRUE") {
marketingPhone.prop('checked',true);
marketingPhone.val('TRUE');
} else {
marketingPhone.prop('checked',false);
marketingPhone.val('FALSE');
}
});
});
And the HTML pieces:
<input id="marketingrules" name="marketingBBB" type="checkbox" class="radio-button-input" value="TRUE">
<input id="marketing" name="marketingAAA" type="checkbox" class="radio-button-input" value="TRUE">
<input type="hidden" name="marketingPhone" value=""/>
Aucun commentaire:
Enregistrer un commentaire