• Resolved hsntgm

    (@hsntgm)


    Hello,

    Do i miss something or all checkboxes have same fieldname if i group them?

    For Example;

    Checkbox 1 = fieldnameX
    ? x1
    ? x2
    ? x3

    FieldnameX also assigned to x1,x2 and x3 ?

    Because i have lots of checkboxes and i have to rule them if one of them checked the other one will be readonly.

    Thanks.

    • This topic was modified 7 years, 10 months ago by hsntgm.
    • This topic was modified 7 years, 10 months ago by hsntgm.
    • This topic was modified 7 years, 10 months ago by hsntgm.
    • This topic was modified 7 years, 10 months ago by hsntgm.
    • This topic was modified 7 years, 10 months ago by hsntgm.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    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, 10 months ago by hsntgm.
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Checkbox groups don’t assign separate fieldnames to group’s elements.’ is closed to new replies.