• Resolved Dimono

    (@dimono)


    Hi there,

    So I created a subscription form. I do want people to choose out of some available lists. But only one. So basically the list needs to be a radio button instead of a checkbox.

    How can I resolve this? Is there an option or a fix to change the checkboxes into radio buttons?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter Dimono

    (@dimono)

    I solved it by adding a little javascript to my header with the following snippet:

          function mailpoet_radio() {
            ?>
          <script type="text/javascript">
               jQuery(document).ready(function(){      
          // Select by input type
          // const checkboxes = document.querySelectorAll("input[type='checkbox']");
          // Select by class
          const checkboxes = document.querySelectorAll(".mailpoet_checkbox");
    
          checkboxes.forEach(checkbox => {
            checkbox.setAttribute("type", "radio");
          });
                    });
                  </script>
          <?php
          }
          add_action( 'wp_head', 'mailpoet_radio' );

    But it would still be a nice feature suggestion. As this now applies to all mailpoet forms.

    Plugin Author MailPoet

    (@mailpoet)

    Hi @dimono

    Thanks for sharing your solution with us.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Choose only one out of lists’ is closed to new replies.