I have a dropdown which is reading from two different categories (catid: 12 and catid: 13) and grabbing the "created_by_alias" field in my database. I would like the two radio groups that are in different categories (catid: 12 and catid:13) to show the "title" field with only the options that would match the selected "created_by_alias" field from the dropdown. Is there a tutorial anywhere on how I accomplish this or can anyone give me any pointers?
Here is a screenshot -

Thanks,
Matt
CFv6
Joomla 3.8.13
Here is a screenshot -

Thanks,
Matt
CFv6
Joomla 3.8.13
It's pretty much the same as for populating a dropdown from a database read.
Ok, so I do a read from the dropdown?
set the options to {var:field_select13}
Do I need to set up an event onchange trigger and run a function?
Sorry, first time attempting this
Matt
set the options to {var:field_select13}
Do I need to set up an event onchange trigger and run a function?
Sorry, first time attempting this
Matt
Have a look at the dynamic dropdown demo form, just use a radios group instead of the second dropdown.
Thanks healyhatman, didn't realize there was a demo... I've modified the demo to test out what I am trying to do and I'm just lost on the syntax for the options in the second dropdown. I need something like this:
I know this is not correct but I'm going in circles trying to figure out how this is supposed to be. My first dropdown is pulling the data from {var:read_data7} and it is working as I intended grabbing from 'data6.created_by_alias' and 'data6.introtext' from the database. I'd like to have the second dropdown show the 'data6.title' in 'catid:12' as options based on the 'data6.created_by_alias' selection. I'm hoping I explained that correctly...
thanks,
Matt
$options = [];
switch($this->data('what_do_you_think')){
$options = 'data6.title';
}
return $options;
I know this is not correct but I'm going in circles trying to figure out how this is supposed to be. My first dropdown is pulling the data from {var:read_data7} and it is working as I intended grabbing from 'data6.created_by_alias' and 'data6.introtext' from the database. I'd like to have the second dropdown show the 'data6.title' in 'catid:12' as options based on the 'data6.created_by_alias' selection. I'm hoping I explained that correctly...
thanks,
Matt
Needs to return an array, you've just set options to a string.
ok, so I assume I need another read data?
I've tried this with a new read data -
I've tried this with a new read data -
$options = [];pretty sure my syntax is messed up tho, can't figure out where I'm going wrong...
switch($this->data('what_do_you_think')){
$options = '{var:read_data8}';
}
return $options;
I too am pretty sure you have that syntax wrong why do you have a switch statement in there
Yeah, sorry I'm not very well versed with php but I'm trying to learn... I was trying to modify the demo for a dynamic dropdown which has options that are set right in the code.
$options = [];I'll be honest, I'm completely lost on how the syntax is supposed to look. I've been scouring the forum but cannot find a similar situation to emulate.
switch($this->data('what_do_you_think')){
case 'good':
$options = ['1' => '1', '2' => '2', '3' => '3'];
break;
case 'bad':
$options = ['-1' => '-1', '-2' => '-2', '-3' => '-3'];
break;
case 'so':
$options = ['good' => 'Good', 'bad' => 'Bad'];
break;
}
return $options;
Looks fine, what have you got in the options list of your radio field, what have you got in your reload action, what IS it doing?
What looks fine? My code or the demo code? I was just showing what was in the demo because you asked why I was using the switch statement...
I've been modifying the demo code to see if I can get this to work
this is what I currently have -






I've been modifying the demo code to see if I can get this to work
this is what I currently have -







in the radio options change it to {var:read_data#.model} replacing # and model with whatever they're supposed to be the writing is tiny and I'm tired
changed it to -
still not working...
Am I supposed to change the switch statement to something else or remove it?
$options = [];
switch($this->data('what_do_you_think')){
$options = '{var:read_data8.data6.created_by_alias}';
}
return $options;
still not working...
Am I supposed to change the switch statement to something else or remove it?
you can't use shortcodes in PHP. $this->get("blahblah", "") instead.
The switch statement is like saying if $variable is A, do this. If it's B, do this. If it's C etc etc. the way you have it now won't work.
Do you have a custom code block after it with {view:field_identifier}?
The switch statement is like saying if $variable is A, do this. If it's B, do this. If it's C etc etc. the way you have it now won't work.
Do you have a custom code block after it with {view:field_identifier}?
ok now I have -
$options = [];There is a custom code after it that was already there from the demo
($this->get('what_do_you_think')){
$options = '{var:read_data8.data6.created_by_alias}';
}
return $options;
{view:field_select2}and in the dropdown called "field_select2" I have
{var:options}I can see the second dropdown (field_select2) which is only populated with the "None" option and when I select an option from the first dropdown (field_select1) I just get a spinning wheel as if it is searching...
0=None
When I said you can't use shortcodes in PHP I meant you can't use {var:xxxxxx}.
Also your code makes absolutely no sense🙂
You don't even need the PHP in there, now that I've understood more clearly what you're trying to do. Get rid of the PHP block, and in your dropdown field_select2, put
Make sure your read data action is set to "Return an array of key/value pairs"
Also your code makes absolutely no sense🙂
You don't even need the PHP in there, now that I've understood more clearly what you're trying to do. Get rid of the PHP block, and in your dropdown field_select2, put
{var:read_data8}
Make sure your read data action is set to "Return an array of key/value pairs"
That puts me back to where I originally started...
The picture in my first post explains what I'm trying to do. I want the first dropdown to show the "created_by_alias" field from two categories (this I already have set). After selected, I would like the second dropdown to show everything that matches the first dropdown selection but display the "title" field associated with the first selection in just one of those categories.
I have a store name set as the "created_by_alias" field which falls in multiple categories (this is the first dropdown)
when the store name is selected I want the second dropdown to show the multiple "title" options from category 12 that are associated with the store name
and third dropdown to show category 13
Hope I explained that correctly
The picture in my first post explains what I'm trying to do. I want the first dropdown to show the "created_by_alias" field from two categories (this I already have set). After selected, I would like the second dropdown to show everything that matches the first dropdown selection but display the "title" field associated with the first selection in just one of those categories.
I have a store name set as the "created_by_alias" field which falls in multiple categories (this is the first dropdown)
when the store name is selected I want the second dropdown to show the multiple "title" options from category 12 that are associated with the store name
and third dropdown to show category 13
Hope I explained that correctly
Hang on sorry let me try make sure I have this.
On Load: Read data --> Display Dropdown 1
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Dropdown 2
On selecting something from Dropdown 2: Read data based on Dropdown 2 selection --> Display radio buttons
Is that right? All you're stuck with is trying to get the right information displayed on the Radio buttons?
On Load: Read data --> Display Dropdown 1
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Dropdown 2
On selecting something from Dropdown 2: Read data based on Dropdown 2 selection --> Display radio buttons
Is that right? All you're stuck with is trying to get the right information displayed on the Radio buttons?
Sorry if I'm confusing... I was using dropdowns for everything because I assumed I could use the
same data in a Radio Button later once I figured out the code...
This is what I would like -
On Load: Read data --> Display Dropdown 1 (cat12 & cat13 "created_by_alias")
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Radio Buttons 1 (cat12 "title")
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Radio Buttons 2 (cat13 "title")
I would like two separate radio buttons based on the initial selection in Dropdown 1
same data in a Radio Button later once I figured out the code...
This is what I would like -
On Load: Read data --> Display Dropdown 1 (cat12 & cat13 "created_by_alias")
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Radio Buttons 1 (cat12 "title")
On selecting something from Dropdown 1: Read data based on Dropdown 1 selection--> Display Radio Buttons 2 (cat13 "title")
I would like two separate radio buttons based on the initial selection in Dropdown 1
OK so you should be able to do that. In your event tab of the drop down, where you have the onchange->reload event, put the names of the two radio select fields on separate lines like this in the field identifier
myRadioField1In the "reload event" field of each of those radio fields you'll need separate events, one for the first radio select group and one for the second. Then put in the requisite {var:read_data#} in their options
myRadioField2
Do I need a php action for this to work? I've been trying all kinds of different things in the options box of the radio group and the only thing I can get to work is if I read directly from the {var:read_data7} function but this just loads the same fields that I have in the 1st dropdown and nothing happens when I make a selection... I can't figure out the syntax to get {var:read_data7.title} or {var:field_select1.title} based on the selection in the 1st dropdown.
I've set the onchange and the reload events as you have suggested but am getting nowhere. I can see the radio group but it stays blank
Here is a frontend view
http://coupons.cuttingcoupons.net/index.php?option=com_chronoforms6&chronoform=dynamic-test
I've set the onchange and the reload events as you have suggested but am getting nowhere. I can see the radio group but it stays blank
Here is a frontend view
http://coupons.cuttingcoupons.net/index.php?option=com_chronoforms6&chronoform=dynamic-test
Think I've figured out how to do this...
I found a thread here:
https://www.chronoengine.com/forums/posts/t103555/2-dynamic-dropdonw-based-on-db-table.html
seems to do what I need, I'll just have to modify it for my purpose
I found a thread here:
https://www.chronoengine.com/forums/posts/t103555/2-dynamic-dropdonw-based-on-db-table.html
seems to do what I need, I'll just have to modify it for my purpose
Show me the read data action in the event that you use to reload the radio fields, and the name of the fields you want for the value and the label
I'm able to get the data from the first pulldown into the first radio group, so I've gotten somewhere...
This is the read data that I used to populate the radio group -

The 1st pulldown (storename) shows the "created_by_alias" field from the DB. You can see below that the store "A Pea in the Pod" is showing up twice. There are two instances where this happens to be the "created_by_alias". I'd like to just show the field once in the pulldown and have the radio group show the multiple "title" fields from a specific "catid" field in the database (catid = 12)

So, the user selects "A Pea in the Pod" from the pulldown and the radio group would show the following "title" fields from "catid"12
Currently it seems to be only showing the one "title" from each selection

The value of each radio group selection is in the "introtext" field of the database which would be 26.65 and 1.0 for the examples shown above
Here is the database -
This is the read data that I used to populate the radio group -

The 1st pulldown (storename) shows the "created_by_alias" field from the DB. You can see below that the store "A Pea in the Pod" is showing up twice. There are two instances where this happens to be the "created_by_alias". I'd like to just show the field once in the pulldown and have the radio group show the multiple "title" fields from a specific "catid" field in the database (catid = 12)

So, the user selects "A Pea in the Pod" from the pulldown and the radio group would show the following "title" fields from "catid"12
Up to 26.65% Off A Pea in the Pod Gift Cards - (Cardcash)
A Pea in the Pod - Get Up To 1.0% Cash Back (Ebates)
Currently it seems to be only showing the one "title" from each selection

The value of each radio group selection is in the "introtext" field of the database which would be 26.65 and 1.0 for the examples shown above
Here is the database -

If you want only one "A Pea in the Pod" to show up you will need to retrieve DISTINCT(model.field_name):model.alias
And try using created_by_alias as your dropdown value and in your where condition, since it looks like you're using "title" which again appears to actually be "Up to 26.5% blahblahblah"
Also I wouldn't use introtext, I'd use the id for the value of the radio group.
And try using created_by_alias as your dropdown value and in your where condition, since it looks like you're using "title" which again appears to actually be "Up to 26.5% blahblahblah"
Also I wouldn't use introtext, I'd use the id for the value of the radio group.
That did the trick, I was getting hung up on the syntax for the where conditions in my read event but I figured it out. For anyone wondering this is what I came up with to pull the correct data:

"storename" being the ID of my dropdown
"created_by_alias" and "catid:12" the fields in the database

"storename" being the ID of my dropdown
"created_by_alias" and "catid:12" the fields in the database
This topic is locked and no more replies can be posted.