• Resolved dkennerson

    (@dkennerson)


    I want to change the value of a checkbox if a different checkbox choice is set to true.

    The logic is something like this:

    If checkbox choice 1 is set to true, then the value of checkbox choice 7 is X. Else, if checkbox choice 1 is set to false, then the value of checkbox choice 7 is Y.

    Any help is appreciated.

    Thanks!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author codepeople

    (@codepeople)

    Hello @dkennerson,

    The behavior you are requesting is specific to your project, and can be confuses for the users, however, if you want move on with it, will be require some of javascript code:

    – First, assign an unique class name to the field, for example: my-field

    Note: the class names are assigned to the fields through their properties: “Add CSS Layout Keywords”

    – Second, insert a “HTML Content” field in the form with a piece of code similar to the following one as its content:

    <script>
    jQuery(document).on('change', '.my-field input', function(){
    var x = 10, y = 100, value;
    if(jQuery('.my-field input:eq(0)').is(':checked')) value = x;
    else value = y;
    
    jQuery('.my-field input:eq(6)').val(value);
    });
    </script>

    The indices start in zero, so, the first checkbox would be :eq(0), and the seventh :eq(6)

    If the first checkbox is ticked the value would be x, if not the value would be y.

    Best regards.

    Thread Starter dkennerson

    (@dkennerson)

    Perfect! Thanks for the quick solution.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Change Checkbox Value’ is closed to new replies.