Forums

Using a {var:read_data##} in a Switch function

U Can Drive 17 Nov, 2018
I am trying to use a Switch function to update data in other fields.
Example -
read_data1 makes an array from the aid/aid fields in a database, this is then presented to a dropdown menu.
read_data2 makes an array from the aid/result fields in the same database.
read_data3 makes an array from the aid/result2 rields in the same database.

I want to select the aid number from the dropdown menu and two text fields produce the corresponding "result" and "result1" data.

I have set up a switch function that is working using the list
1:One
2:Two
3:Three
4:Four
5:Five

I've tried puting {var:read_data12} in the switch "Values Setup" list and selected "Handle data arrays" hoping it would work, but the result is just blank...

Am I entering the array incorrectly? Should I be reading this data differently?
If so could you please instruct me how to do this properly, thank you.
healyhatman 17 Nov, 2018
{var:read_data12.model.field}
U Can Drive 17 Nov, 2018
Thank you, I put that in the "Values Setup" of the Switch but still coming in blank😟
healyhatman 17 Nov, 2018
1) make sure you have it set to first record found

2) turn off handle arrays

Or is var:read_data.[n].model.field
U Can Drive 17 Nov, 2018
1) Doesn't make sense, don't I need the array of all the values? Tried it anyway, didn't change anything.
2) I had tried that but no change.

I don't understand what the last line is doing, and it doesn't do anything different either.
healyhatman 17 Nov, 2018
You might just need to explain in more detail what it is you're trying to do, because I don't know if a switch is the right way to do it. And paste a debug in here.
U Can Drive 17 Nov, 2018
I've linked the page I'm using to figure out how to do this, it has other stuff, just ignore that, this is my play space🙂

When using the top drop down "Number" I want the field called "Code" (4th one down) to give the corresponding answer.
The list of answers is also loaded into the "Code List" drop down for reference.

So if you select 1 in "Number", "Code" should return the value 0264EA3

https://ucandrive.com.au/index.php?option=com_chronoforms6&chronoform=testform-copy

The debug at page load:
Array
(
    [read_data18] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `Data`.`aid` AS `Data.aid`, `Data`.`aid` AS `Data.aid` FROM `00_UCD_PurchaseDetails` AS `Data` GROUP BY `Data.aid` LIMIT 100;
                )

            [var] => Array
                (
                    [1] => 1
                    [2] => 2
                    [3] => 3
                    [4] => 4
                    [5] => 5
                    [6] => 6
                    [7] => 7
                    [8] => 8
                    [9] => 9
                    [10] => 10
                    [11] => 11
                    [12] => 12
                    [13] => 13
                    [14] => 14
                    [15] => 15
                    [16] => 16
                    [17] => 17
                    [18] => 18
                    [19] => 19
                    [20] => 20
                    [21] => 21
                    [22] => 22
                    [23] => 23
                    [24] => 24
                )

        )

    [read_data19] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `Data`.`aid` AS `Data.aid`, `Data`.`StudName` AS `Data.StudName` FROM `00_UCD_PurchaseDetails` AS `Data` LIMIT 100;
                )

            [var] => Array
                (
                    [1] => First Last
                    [2] => First Last
                    [3] => First Last
                    [4] => First Last
                    [5] => First Last
                    [6] => First Last
                    [7] => First Last
                    [8] => First Last
                    [9] => First Last
                    [10] => First Last
                    [11] => First Last
                    [12] => First Last
                    [13] => First Last
                    [14] => First Last
                    [15] => First Last
                    [16] => First Last
                    [17] => First Last
                    [18] => First Last
                    [19] => First Last
                    [20] => First Last
                    [21] => First Last
                    [22] => First Last
                    [23] => First Last
                    [24] => First Last
                )

        )

    [read_data20] => Array
        (
            [log] => Array
                (
                    [0] => SELECT `Data`.`aid` AS `Data.aid`, `Data`.`PCode` AS `Data.PCode` FROM `00_UCD_PurchaseDetails` AS `Data` GROUP BY `Data.aid` LIMIT 100;
                )

            [var] => Array
                (
                    [1] => 0264EA3
                    [2] => 250F413
                    [3] => 023F757
                    [4] => 247481E
                    [5] => 61F2A28
                    [6] => A4201B8
                    [7] => 675A25F
                    [8] => 44779B8
                    [9] => BD6BD90
                    [10] => 0C28C3D
                    [11] => CE347FC
                    [12] => A3E0110
                    [13] => 8440A72
                    [14] => C213495
                    [15] => 0255448
                    [16] => 419F354
                    [17] => BF7CEE2
                    [18] => F71A251
                    [19] => A7B8C21
                    [20] => 343D3A0
                    [21] => D653EF9
                    [22] => C65C0FE
                    [23] => DD8EE01
                    [24] => 040E064
                )

        )

)
healyhatman 17 Nov, 2018
Havea look at the dynamic dropdown demo maybe
U Can Drive 17 Nov, 2018
Yeah, that just provides a second set of options rather than selecting the appropriate answer.
healyhatman 17 Nov, 2018
Ah well it's the same idea you just put the value you want in the value or selected value box.
U Can Drive 17 Nov, 2018
Got it working!

Your call that using a switch may not be the best work fixed it for me, I'm simply reading the file for the answer rather than selecting the answer from a pre-loaded list.

Thank you for your time, I really appreciate it!
shahabpk 25 Oct, 2019
How did you solve the problem?
This topic is locked and no more replies can be posted.