Support

Account

Home Forums General Issues Live update ACF fields form with values in labels

Solving

Live update ACF fields form with values in labels

  • Hello,

    I have created a form using ACF fields. Now I need that the value in for example selected by user on front-end “select field” would appear in that fields label for him as soon as it is selected, so the field label should be live updated before submitted. How can I achieve this? I tried shortcodes and PHP, but couldn’t make it work. I also tried select field value to appear in message field, but no luck. Kindly please help.

  • You would have to do this using JavaScript

    https://www.advancedcustomfields.com/resources/adding-custom-javascript-fields/

    I don’t know of any examples for doing this.

  • I got this working.

    <form>
      <label for="inputField01">Employee #01:</label>
      <input type="text" id="inputField01" value="John Doe">
    </form>
    
    jQuery(document).ready(function($) {
    	$('#inputField01').on('input', function() {
    	  $('label[for="inputField01"]').text('Employee #01: ' + $(this).val());
    	});
    	$('label[for="inputField01"]').text('Employee #01: ' + $('#inputField01').val());
      });
    

    Hope this helps.

Viewing 3 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic.