Hi.
I have a form that uses several tables that using small forms for CRUD with Chronoforms V4 and Chronoconnectivity.
Now, I need to "join" the info of some of the forms in one big form.
For example; I have a form that list & updates "machines", with info about name, serial number, and color.
On the big form, I need to select which machine I want to use (with a "drop down"), and I have no problem to recover this list with machine names and assign to a select list.
But I'm unable to recover the rest of machine information and assign the values to other text-boxes of the form, and "dinamicaly" fill this fields with this data. Note that the selection of the machine is after the form is loaded, and before submission.
I've tried several methods, including some javascripts events, DB Record Loader but only on On Load event. No luck.
Suggestions will be very appreciated;
I have a form that uses several tables that using small forms for CRUD with Chronoforms V4 and Chronoconnectivity.
Now, I need to "join" the info of some of the forms in one big form.
For example; I have a form that list & updates "machines", with info about name, serial number, and color.
On the big form, I need to select which machine I want to use (with a "drop down"), and I have no problem to recover this list with machine names and assign to a select list.
But I'm unable to recover the rest of machine information and assign the values to other text-boxes of the form, and "dinamicaly" fill this fields with this data. Note that the selection of the machine is after the form is loaded, and before submission.
I've tried several methods, including some javascripts events, DB Record Loader but only on On Load event. No luck.
Suggestions will be very appreciated;
Hi neuronageek,
If you need to load information after the form is loaded and before it is submitted then you probably need to use Ajax - that is JavaScript that will send a query back to the server to get an extra chunk of information. This works quite smoothly an neatly in most cases.
You put an Ajax query into a Load JS action to create the query on a form event - like a drop-down selection being made; and add PHP in a new Event in your form to get the data and send it back.
The ChronoForms Dynamic Drop-down action in the Power Fields Group is a basic Ajax implementation for changing the options of one drop-down depending on the selection in another.
If you search the FAQs on Ajax you will find a bit more information.
Bob
If you need to load information after the form is loaded and before it is submitted then you probably need to use Ajax - that is JavaScript that will send a query back to the server to get an extra chunk of information. This works quite smoothly an neatly in most cases.
You put an Ajax query into a Load JS action to create the query on a form event - like a drop-down selection being made; and add PHP in a new Event in your form to get the data and send it back.
The ChronoForms Dynamic Drop-down action in the Power Fields Group is a basic Ajax implementation for changing the options of one drop-down depending on the selection in another.
If you search the FAQs on Ajax you will find a bit more information.
Bob
Hi, Bob. Thanks for your support.
I'm getting some process working.
Following your advice, I put a Dynamic DropDown in "On Load Event", before "Show html" with this config:
Action label: Cargador de Establecimientos
Source Dropdown ID: establecimiento_ac [NOTE: It's "FIELD NAME content box, not FIELD ID box. Using FIELD ID data results in javascript erros (id not found), at least if source select its a "Custom Element PHP/HTML", wich I fills with a custom query to a table]
Target Dropdown ID: etb_aci_input [NOTE: This is FIELD ID BOX OK!!!. Its a standard dropdown]
Both dropdowns must shows the same info "selected" but only the first (the source) is "selectable". The other, is also "readonly".
I create a Ajax event "cargaestablecimiento" wich link both items and OK, when I change the first select list, the second changes and get the same value.
To do this, I create a DBMulti Record Loader who theorically create a key under form->data to store the information I recover from the query using "model ID". I called this "recs_est".
I pretends to recover te following fields (using fields box):
NOTE: Very tricky, do not use white space afeter a comma....
On WHERE box y put the following to filter records:
`nombre_establecimiento` LIKE '%<?php echo $form->data['establecimiento_ac'];?>%'
(at this time, I select using the name of the items 😶 )
Finally, I add a Custom Code action under DB MultiRecord Loader, with this code:
An now, my questions:
- ¿How I must assign the value retorned on target select in order to be "saved" when pressing "Submit"? At this time, the associate field of select with database is not updated when a change is fired.
- How can I populate the other info I recover under $form->data['recs_est'] to assign, for example to input boxes and be able to be modified and storeds under the table asigned to actual form when submiting?
This will value more than hundred beers...
I'm getting some process working.
Following your advice, I put a Dynamic DropDown in "On Load Event", before "Show html" with this config:
Action label: Cargador de Establecimientos
Source Dropdown ID: establecimiento_ac [NOTE: It's "FIELD NAME content box, not FIELD ID box. Using FIELD ID data results in javascript erros (id not found), at least if source select its a "Custom Element PHP/HTML", wich I fills with a custom query to a table]
Target Dropdown ID: etb_aci_input [NOTE: This is FIELD ID BOX OK!!!. Its a standard dropdown]
Both dropdowns must shows the same info "selected" but only the first (the source) is "selectable". The other, is also "readonly".
I create a Ajax event "cargaestablecimiento" wich link both items and OK, when I change the first select list, the second changes and get the same value.
To do this, I create a DBMulti Record Loader who theorically create a key under form->data to store the information I recover from the query using "model ID". I called this "recs_est".
I pretends to recover te following fields (using fields box):
cf_id,tipo_establecimiento,nombre_establecimiento,direccion_establecimiento,poblacion_establecimiento,provincia_establecimiento,contacto_establecimiento,telefono_cto_establecimiento
NOTE: Very tricky, do not use white space afeter a comma....
On WHERE box y put the following to filter records:
`nombre_establecimiento` LIKE '%<?php echo $form->data['establecimiento_ac'];?>%'
(at this time, I select using the name of the items 😶 )
Finally, I add a Custom Code action under DB MultiRecord Loader, with this code:
<?php
$results = array();
$results[] = '';
$selected = "selected='selected'";
foreach ( $form->data['recs_est'] as $v ) {
$results[] = $v['cf_id'].'='.$v['nombre_establecimiento'];
}
$results = implode("\n", $results);
echo $results;
$form->data['establecimiento_ac_i']=$form->data['recs_est']['nombre_establecimiento'];
$mainframe =& JFactory::getApplication();
$mainframe->close();
?>
An now, my questions:
- ¿How I must assign the value retorned on target select in order to be "saved" when pressing "Submit"? At this time, the associate field of select with database is not updated when a change is fired.
- How can I populate the other info I recover under $form->data['recs_est'] to assign, for example to input boxes and be able to be modified and storeds under the table asigned to actual form when submiting?
This will value more than hundred beers...
Hi neuronageek,
The Double Drop-Down action is designed to link two drop-downs.
If you want to make other changes in a form using Ajax then you need to hand-code the JavaScript to call the action and handle the reply.
I just posted for someone else a link to this post where I have shown part of the code build a triple drop-down. Your code will be similar (but simpler). You use the onSuccess() function of the Request.JSON() call to set the values of other inputs in your form.
Bob
The Double Drop-Down action is designed to link two drop-downs.
If you want to make other changes in a form using Ajax then you need to hand-code the JavaScript to call the action and handle the reply.
I just posted for someone else a link to this post where I have shown part of the code build a triple drop-down. Your code will be similar (but simpler). You use the onSuccess() function of the Request.JSON() call to set the values of other inputs in your form.
Bob
This topic is locked and no more replies can be posted.