• Resolved dejanlero

    (@dejanlero)


    I need to have 1 selection between 2 radio button forms. i could just rename the radio button name to the other one and fix it but since i cant find the code how do i do that from the menu?

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

    (@codepeople)

    Hello @dejanlero

    I’m sorry, but I don’t understand the request. Could you provide additional details, please?

    Best regards.

    Thread Starter dejanlero

    (@dejanlero)

    @codepeople I have a question with 2 radio button forms in different places for yes or no, only 1 radio button is supposed to be clicked out of the 2 in BOTH forms.

    example:
    1st radio button form
    Check this list if you are not a company
    are you 40 years and under ?
    yes no

    2nd radio button form
    check in this list if you are a company
    are your shareholders are mostly over 40
    yes no

    he can either be a company or single person and i cant link the 2 radio button forms together for 1 answer to the question.

    Hopefully you understand what i mean as i cant share any website data

    Plugin Author codepeople

    (@codepeople)

    Hello @dejanlero

    If I understood you correctly, you have a radio button field with two options. And depending on the option selected by the user, you want to display a second radio button field with other options.

    In this case, you can insert three radio buttons, the main radio button with the two initial options, and the other two radio buttons whose options are related to the corresponding choices of the main field. Finally, you can configure the two additional radio buttons fields as dependent on the choices in the main one.

    More information about dependencies by reading the following blog post:

    https://cff.dwbooster.com/blog/2020/03/01/dependencies

    Best regards.

    Thread Starter dejanlero

    (@dejanlero)

    I need both of the forms to be displayed and cant use dependencies

    View post on imgur.com

    As shown in the image they should be able to only check one of the radio buttons

    The form is in a different language but the answers are yes and no.

    its either the first yes or no OR the second yes or no

    Plugin Author codepeople

    (@codepeople)

    Hello @dejanlero

    In this case, assuming the radio buttons are the fieldname1 and fieldname2, you can insert an “HTML Content” field in the form with the following piece of code as its content:

    <script>
    jQuery(document).on('change', '[id*="fieldname1_"]', function(){
    var v = jQuery('[id*="fieldname1_"]:checked').val();
    jQuery('[id*="fieldname2_"][value="'+v+'"]').prop('checked', true);
    });
    
    jQuery(document).on('change', '[id*="fieldname2_"]', function(){
    var v = jQuery('[id*="fieldname2_"]:checked').val();
    jQuery('[id*="fieldname1_"][value="'+v+'"]').prop('checked', true);
    });
    </script>

    Remember to replace in the previous code the fields’ names with the correct ones.

    Best regards.

    Thread Starter dejanlero

    (@dejanlero)

    @codepeople

    Is it possible to edit names of radio buttons in this plugin ?

    Plugin Author codepeople

    (@codepeople)

    Hello @dejanlero

    No, I’m sorry, the fields’ names are generated dynamically, and you cannot rename them. However, you can assign class names to the fields and use these classes as selectors.

    Assign the class names to the fields through their attributes: “Add CSS Layout Keywords.”

    For example, if you assign the radio-1 class name to the first radio button and radio-2 to the second one, the code I included in the previous entry can be edited as follows:

    <script>
    jQuery(document).on('change', '.radio-1 input', function(){
    var v = jQuery('.radio-1 input:checked').val();
    jQuery('.radio-2 input[value="'+v+'"]').prop('checked', true);
    });
    
    jQuery(document).on('change', '.radio-2 input', function(){
    var v = jQuery('.radio-2 input:checked').val();
    jQuery('.radio-1 input[value="'+v+'"]').prop('checked', true);
    });
    </script>

    Best regards.

    Thread Starter dejanlero

    (@dejanlero)

    They both check at the same time, could you edit the code because i dont know how to, if the radio-1 input is checked then you cant check the radio-2 because the code will uncheck radio-1 ?

    Plugin Author codepeople

    (@codepeople)

    Hello @dejanlero

    Please, if you need a custom coding service, do not hesitate to contact me through my private website: Custom Coding Service

    Best regards.

Viewing 9 replies - 1 through 9 (of 9 total)

The topic ‘Linking 2 radio button forms’ is closed to new replies.