Created
March 22, 2024 16:39
-
-
Save snrjosh/de7c21c201bda4c779c1b3af62e03b47 to your computer and use it in GitHub Desktop.
WPForms - Populate a field from another field on same form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Populate a field from another field on same form | |
* | |
* @link https://wpforms.com/developers/how-to-pre-populate-fields-in-the-same-form/ | |
*/ | |
add_action( 'wpforms_wp_footer_end', function() { | |
?> | |
<script> | |
jQuery(function($){ | |
var formID = 22397; // Change form ID | |
var faxNumber = 7; // Fax number field ID to grab value | |
var faxEmail = 8; // Fax email field ID to pass value to | |
$( '#wpforms-' + formID + '-field_' + faxNumber ).on( 'change', function() { | |
$( '#wpforms-' + formID + '-field_' + faxEmail ).val($(this).val().concat("concatenate some text here")); | |
}); | |
}); | |
</script> | |
<?php | |
}, 10 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment