Forums

Chronoforms V6 - Use dropdown data for onchange

theorgfarm 13 May, 2020
Hello,

I am using dropdowns to collect data and based on change in that data, I need to calculate a value and display in another field. This needs to be done before the form is submitted.

But in the onchange function I wrote when I try to read the value of the selected dropdown field, I am getting undefined value.

Can you pls let me know how to get this done?

Regards,
Alladi
Max_admin 13 May, 2020
Hi Alladi,

If you still experimenting with this then I recommend that you download v7 beta2 and try it:
http://www.chronoengine.com/blog

Does it work better ?
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
theorgfarm 13 May, 2020
Hi Max,

I need a fix urgently. If possible can I use PHP code to calculate and set the form data after submit and before DBsave?

But unfortunately, I am unable to find the proper syntax to access form data in Chronoforms v6.

This is the code I used. I want to calculate "tot" field from dp1 and dp2 (both dropdowns). The following is the code I used and the debug data.
$t = $this->data("dp1",0) + $this->data("dp2", 0);
$this->set("tot", $t);
return 1;

Debug Data

Array
(
    [option] => com_chronoforms6
    [cont] => manager
    [chronoform] => Test Form
    [event] => submit
    [dp1] => 2
    [dp2] => 2
    [tot] => 
    [button3] => 
)
Array
(
    [submit_validate_fields] => Array
        (
            [log] => Automatic validation enabled.
            [var] => 1
        )

    [php10] => Array
        (
            [returned] => 1
            [var] => 1
        )

    [save_data8] => Array
        (
            [data] => Array
                (
                    [tot] => 
                    [dp1] => 2
                    [dp2] => 2
                )

            [_success] => Data saved successfully
            [log] => Array
                (
                    [0] => INSERT INTO `enjte_chronoforms_data_return_test` (`tot`, `dp1`, `dp2`)  values  ('', '2', '2');
                )

            [var] => Array
                (
                    [tot] => 
                    [dp1] => 2
                    [dp2] => 2
                    [aid] => 81
                )

        )

)
Kindly guide me as the requirement is urgent.
Max_admin 14 May, 2020
$this->set("tot", $t);
should be:
$this->data["tot"] = $t;
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.