Hello, I would like to ask how can I live update or populate a certain Field with the value of the on the selected radio button?
Example:
Radio button: A:1 B:2 C:3 D:4
When radio button D is selected the container field will update with the value selected on the radio button.
Container Field Dislplay = 4
I don’t know if I explained it well but I want to populate the Container Field with the value selected on the radio button first before submitting.
Is there a way to do this? Thank you.
I don’t know if this code helps.
add_action( 'gform_pre_submission_121', 'gaf_product' );
function gaf_product( $form ) {
// initialize variables to hold the counts
$gaf_product1 = 0;
$gaf_product2 = 0;
GFCommon::log_debug( __METHOD__ . '(): POST => ' . print_r( $_POST, true ) );
if($selection = $_POST["input_30"]){
if ( $selection == '120931' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched for Babies." );
$gaf_product1=120931;
}
if ( $selection == '118535' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched for Kids." );
$gaf_product1=118535;
}
if ( $selection == '120946' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched TeenSleep." );
$gaf_product1=120946;
}
if ( $selection == '84522' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched for Adults 30ml." );
$gaf_product1=84522;
}
if ( $selection == '120923' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched for Adults. 50ml" );
$gaf_product1=120923;
}
if ( $selection == '120937' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Menopauzzz." );
$gaf_product1=120937;
}
if ( $selection == '120935' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Menzzz." );
$gaf_product1=120935;
}
if ( $selection == '120939' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Night Immune." );
$gaf_product1=120939;
}
if ( $selection == '120925' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Essential." );
$gaf_product1=120925;
}
if ( $selection == '120929' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Daytime Revive." );
$gaf_product1=120929;
}
if ( $selection == '121002' ){
GFCommon::log_debug( __METHOD__ . "(): input ID => {$input_id} matched Divine." );
$gaf_product1=121002;
}
}
$_POST['input_32'] = $gaf_product1;
$_POST['input_18'] = $gaf_product2;
}
samuel
(Samuel (Gravity Wiz))
September 18, 2021, 3:39am
3
Hi Don,
If you may be interested in using an addon for this, then you should check out our GP Populate Anything Perk. The Live Merge Tags feature would work perfectly for what you’re trying to do.
Dynamically filter and populate field choices and values with posts, users, taxonomies, terms, Gravity Forms entries, and databases.
Est. reading time: 4 minutes
Best,
1 Like
Thank you but I only need two of the fields on this.
I found a code that does similarly but if input_2 is a radio button field will the $_POST[input_7] get the value from the input_2? or it will get the text? Thank you for this.
// copy the email address value over to the admin only password field
add_action('gform_pre_submission_4', 'ch_populate_password');
function ch_populate_password($form){
$_POST['input_7'] = rgpost('input_2');
}
system
(system)
Closed
October 19, 2021, 3:14am
5
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.