Imagining I have a "test_db" database and a "test_tbl" table with 4 columns ("col_id", "col_title", "col_surname", "col_name") I would like that, when I select a value in the "form_id" field, the values of the "col_surname" and "col_name" columns extracted from the row for which the value in "col_id" is the same as that selected in the "form_id" field are automatically inserted in the "form_surname" and "form_name" fields .
I would like to point out that the "form_id" field is of the dropdown type and contains all the ids (values) with the respective titles (texts) present in the "col_id" and "col_title" columns of the "test_tbl" table.
I guess the result can be achieved through the "Read data" action but I don't know how. Can anyone help me by explaining how to set up Chronoforms?
Thanks in advance,
Alex
you can do this now by having a first page where the form_id is selected and then a 2nd page where the rest of fields are displayed and the data is read on first page submit
but if you want the data loaded on "form_id" selection (single page form) then this requires AJAX call and after that the data should be set in the fields, and this can not be handled by v8 now but it's on the todo list
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Hi flyboeing
yes, you can do a Reload or AJAX Call under an Advanced Event Listener to call another page with the Read Data and either:
1 - Reload: reload the fields with the new values
2- AJAX Call: run a JS function to set the fields values
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
correct, a Reload means the "output" of the reload page will replace the "Listener", but your reload page (options) does not return any output, because it has no Views, so you need to add another Text field there
alternatively, use "AJAX Call", and supply the page name (options) and Aa JS function name (set_value), then define this JS function and make it set the value of the "Reg prefix" field, the function will have one supplied parameter which is the result from the AJAX call (the prefix in your case)
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
the Text field should be AFTER the Read Data, and the {var:read_data12.reg_prefix} should be in the Text field "Default Value" behavior, and you need to make sure that the Read Data actually returns a result, you can try to access that page directly in the browser with the form Debug enabled to check this
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
does the reloaded field have the same name as the original one ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
I think it's because the field object changes when it's reloaded, you may need to do it the other way, using AJAX Call and use a function to set the field value:
function(result){
document.querySelector("[name='field-name']").value = result;
}
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
that's ok, but that's what the AJAX listener is doing, it will load the other form page which runs the database and returns a value, then your function can use that value:


and in the next update the function will get a 2nd parameter, the calling field object, so that you can just use it this way:
function(result, field){
field.value = result;
}
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?