Update Dependant Field Label Based On Parent Field Value

In this guide, we will explain how to update the label based on a previous field's value input by the user using JavaScript.

Drag and drop some Fields with a JavaScript field as shown below.

image

Click the pencil icon of the JavaScript field and paste the code.

image

Please use this code:

// Listen to first name field input complete event, once user has entered the value and moved the focus this code will be executed
window.formyoula.form_fields[ 'a7e5-8418-9090' ].on( 'input:set:success', function( options ) {
  // Set Email field label to show first name and some default static text
  window.formyoula.form_fields[ '0e80-8026-70aa' ].set( {
    label: window.formyoula.form_fields[ 'a7e5-8418-9090' ].get( 'value' ) + ' please enter your email'
  } );
} );

Try the form.

image

After entering the First Name field value.

image

For any questions, please get in touch with us - [email protected] or the Formyoula in-app chat 🙂