Hello,
Yes of course the name of checkboxes that belong to a same group are called as follows:
the_field_name[]
To be submited as the values of the same field.
(No exactly the previous name because they depend of the fieldnameX)
For example, if the checkboxes field is the fieldname1, and you want check if the first one is checked, you simply should called the piece of code:
jQuery('[id*="fieldname1_"]:eq(0)').is(':checked')
For the second one:
jQuery(‘[id*=”fieldname1_”]:eq(1)’).is(‘:checked’)
and so on.
as you can see the index begins in zero.
But if the previous code is included as part of an equation (as in the equations all texts with the format fieldname# are replaced by the field’s value), the code to use would be:
jQuery('[id*="fieldname'+'1_"]:eq(0)').is(':checked')
Best regards.
Thread Starter
hsntgm
(@hsntgm)
That is exactly what am i looking for !
Great solution.
You are a javascript god for me.
First Zeus then Codepeople.
Thanks in advance.
And the solution i found, maybe it helps someone.
<script>
jQuery(document).on(
'click',
'[id*="fieldname'+'1_"]:eq(1)', function(){
jQuery(this).val(this.checked ? "TRUE" : "FALSE");
});
</script>
<script>
jQuery(document).on(
'click',
'[id*="fieldname'+'1_"]:eq(1)', function(){
var value = jQuery('[id*="fieldname'+'1_"]:eq(1)').val();
if (value == 'TRUE')
{
jQuery('[id*="fieldname'+'1_"]:eq(3)').prop('disabled', true);
}
else
{
jQuery('[id*="fieldname'+'1_"]:eq(3)').prop('disabled', false);
}
});
</script>
-
This reply was modified 7 years, 7 months ago by hsntgm.