Forums

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

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 20 Mar, 2025
Answer

Hi Maurizio

Please check this:

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.
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 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.
You need to login to be able to post a reply.