How to set corectly the AJAX call for change the value in a field

How to set up an AJAX call to change a field value in ChronoForms.

Overview

The issue is not knowing how to configure the AJAX response to update a field after a trigger event.
Configure the AJAX listener to load a result from a target page, then use a JavaScript function on the form page to set the field value to that result.

Answered
ChronoForms v8
ma mas80082 20 Mar, 2025

I would like to know how to set a AJAX call following an trigger call by a field. In particular what I have to insert in the new page for the AJAX call. It is clear how to set trigger e listener advance, but not clear how to change the value in the field when the trigger is on.  I am using CF8

Many thanks 

Maurizio m

Max_admin Max_admin 20 Mar, 2025
Answer

Hi Maurizio

Please check this:

How to set corectly the AJAX call for change the value in a field image 1

The AJAX will load the result from "page5" and will call a function called "set_value" after the result arrives, this function will get 2 parameters:

  1. The AJAX result, this will be whatever string or HTML you print in page5
  2. The field object which has the listener

So you can add a JavaScript view to your form:

function set_value(result, field){
field.value = result
}

And this will set the value of the field to the AJAX result

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
ma mas80082 20 Mar, 2025

Hi Max many  thanks for your anwer

Just to be sure to have understand propely 

javascript with the fuction must be put in the page5 after a php  for example that elaborate somethihg as a string

Max_admin Max_admin 20 Mar, 2025

no, javascript should be on the same page where the field called the AJAX, that's the page loaded in your browser

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.