Completed

Caldera Form: populate fields based on another field's value (all values come from database)

I'm setting up a form using Caldera Form plugin for a flight delay compensation calculator.

The compensation depends on the distance between airports and the hours of the delay.

OVERVIEW:

User selects two airports (departure and arrival) and the form should calculate the distance between them with the haversine formula.

The DB table will contain airports' names, codes and their coordinates.

Airports' fields will be in the homepage with a submit button. Then the user will be redirect on another page where he can select the hours of the delay and in the end he can see the compensation amount.

MAIN TASK:

When the user selects the departure airport, I need to populate two hidden fields with latitude and longitude of that airport in order to use these values in the formula. I need the same thing for the arrival airport. I'm able to create the formula via javascript but i can't retrieve coordinates based on the dropdown selection of the airport (it's a Select2 field).

I think it should be done via jQuery Ajax and PHP or even only in PHP since forms are in two different pages? Sincerely i don't know, this is entirely up to you.

Thanks

RESOURCES:

This is the code I used to populate the dropdown field with airports name, using the caldera_forms_render_get_field filter :

add_filter( 'caldera_forms_render_get_field', function( $field ) {

if ( 'fld_2313184' == $field[ 'ID' ]) {

global $wpdb;

$airports = $wpdb->get_results("SELECT airports_name FROM airports_table");

if ( ! empty( $airports ) ) {

foreach ($airports as $airports) {

$field[ 'config' ][ 'option' ][ $airports->airports ] = array(

'value' => $airports->airports,

'label' => $airports->airports

);}}}

return $field;

});

Skills: Javascript, jQuery, MySQL, PHP, WordPress

See more: flash php contact form required fields, flash tutorials flash php contact form mandatory fields, acrobat reader form populate fields database, caldera forms conditional recipient, caldera forms calculation value, caldera forms auto populate, caldera forms toggle switch, caldera forms repeatable fields, caldera forms hidden field, caldera forms magic tags, caldera forms dropdown, form field retain value, javascript hide form fields based values, hidingshowing form fields based button click aspnet, showhide form fields based values field, populate fields html form string url, pass value via javascript form hideshow fields, javascript hide rows based field value, form dynamic fields save field database, populate fields adobe form access vba

About the Employer:
( 0 reviews ) Rome, Italy

Project ID: #19258951

Awarded to:

ALIATHERSE

Hi, I have reviewed your job requirements and I am interested in this project and can easily complete this job in minimum time possible with guaranteed results. I am an expert data entry specialist as well as a s More

€23 EUR in 1 day
(0 Reviews)
0.0

4 freelancers are bidding on average €22 for this job

programac

Greetings Gi92val! Thanks for sharing your idea "Caldera Form: populate fields based on another fields value all values come from database". I'm so much focused in your idea and definitely want to get involve. Kindly More

€20 EUR in 1 day
(149 Reviews)
6.3
SiliconSecret

I have great team for Wordpress website design and development, I am very excited for the opportunity to work with you in accomplishing your goals. We have developed thousands of websites in many programming languages More

€25 EUR in 5 days
(2 Reviews)
3.4
mahrishikesh

I AM A WORDPRESS/WOOCOMMERCE PRO AND HENCE CAN RESOLVE YOUR ISSUES FASTER. HANDS ON EXPERIENCE IN WORDPRESS/WOOCOMMERCE FUNCTIONALITY CUSTOMIZATION, HTML TO WORDPRESS LATEST VERSIAON THEME, PLUGIN CUSTOMIZATION A More

€21 EUR in 0 days
(0 Reviews)
0.0