Support » Plugin: Advanced Custom Fields (ACF) » Updated message with repeater field on change of select

  • I have a repeater field that is made up of one field, a select (dropdown menu). Below the repeater field, I have a “Message” field that displays the various selections in the rows with some variables appended. The system works fine, after the post has been saved. However, my client now wants the message to update as soon as a “select” from the repeater is change.

    I am able to detect a change and update the message using the follow code:

    function my_acf_admin_head()
    {
      ?>
     <script type="text/javascript">
      jQuery(function(jQuery){
        jQuery('select').on('change', function() {
          var newmessage="<?php $currentmessage='testing'; echo $currentmessage ?>";
          alert(newmessage);
          jQuery('.themessage').empty();
          jQuery('.themessage').append(newmessage);
        });
      });
    </script>
    <?php
    }
    
    add_action('acf/input/admin_head', 'my_acf_admin_head');

    That, of course, simply appends “testing” into the message. However, I need to loop the repeater field and display all of the “select” selections, as there are typically 3 or 4 rows to the repeaters for this client.

  • The topic ‘Updated message with repeater field on change of select’ is closed to new replies.