Triple Dynamic Dropdown

Tozai_X 21 Aug, 2014
Hi everybody, i'm trying to have working the following form:

Preview
.....some text box before ....
1)first dropdown: Field Name: user_sport_id | Field ID: sportsDrop | Show Empty : Selezionare Sport
2)second dropdown: Field Name: user_ruolo_id | Field ID: rolesDrop | Show Empty : Selezionare Ruolo
3)third dropdown: Field Name: user_categoria_id | Field ID: categoriesDrop | Show Empty : Selezionare Cateogia
.....

Events
On on_load event i have 3 DB multi record loader event for the 3 dropdowns above and 2 dynamic dropdown event:

1) Source ID: sportsDrop | Target ID: rolesDrop | AJAX event : sportsDrop_changed
2) Source ID: rolesDrop | Target ID: categoriesDrop | AJAX event : rolesDrop_changed

On the AJAX events I have(the code is almost the same for both events):

sportsDrop_changed)
1)DB FIeld: sport_id(foreign key field of the table of the second drop down) | Request Param: user_sport_id
2)Custom code:
<?php
    $results = array();
    // the next line set the first 'nothing selected' option.
    $results[] = '-1=Selezionare Ruolo';
    foreach ( $form->data['RolesDataModel'] as $v ) {
        $results[] = $v['id'].'='.$v['ruolo_nome'];
    }
    $results = implode("\n", $results);
    //Ritorno dei valori
    echo $results;
    //Stop esecuzione
    $mainframe =JFactory::getApplication();
    $mainframe->close();
?>

rolesDrop_changed)
1)DB FIeld: ruolo_id(foreign key field of the table of the third drop down) | Request Param: user_ruolo_id
2)Custom code: ----

Now: when i select on the first or second dropdown the "Show Empty" value i've on the connected dropdown this:
--------------------------------------------------------------
"http://www.w3.org/1999/xhtml" xml:lang=

"viewport" content
"content-type" content
"generator" content...
.........
---------------------------------------------------------------
Using the firefox debugger I noticed that the "call index.php?option=com_chronoforms&chronoform=gestione_anagrafica_ita-2&event=sportsDrop_changed" have success and the responsetxt is the content of the *php file.

I have another form with 3 dropdown and when i select the Show Empty value the following dropdowns simply remain empty...

I really don't understand where i'm wrong on this form.

Does anybody can help me?

Thank you very much.
GreyHead 25 Aug, 2014
Hi Tozai_X,

It's not easy to work out from here, Please post a link to the form so I can take a quick look.

It may be that the URL to call the Ajax event needs to include &format=raw to prevent the template being included.

Bob
Tozai_X 26 Aug, 2014
Tnx Bob for your reply.
Yes, you're right: it's not easy πŸ˜€

You can check here: http://www.refermind.com/svil1/

Then Login: "piero@email.it" / "piero1"

and click on "Personalizza Allenamento" in TopMenu to see the form.
The triple Dynamic Dropdowns are at he end of form.

Thank in advance for your help.

PS: where i can include "&format=raw" ? In "AJAX Event Name" Field?

MT
GreyHead 27 Aug, 2014
Hi MT,

The drop-downs there appear to be working correctly. Where are the ones that don't'work?

Bob
Tozai_X 27 Aug, 2014
Really?!?
If I select "Seleziona Sport" on the first dropdown...

Check the attachment.
[attachment=0]Triple.png[/attachment]
GreyHead 27 Aug, 2014
Hi Tozai_X,

Sorry, I didn't look in the right place :-(

What you are getting back then is an empty web page with just the template (see image). I'm not clear if that is because the link isn't going to the form or if there is an error in your PHP. Adding the -1 entry to the results does look odd.

I wonder, does the DB Read in the Ajax event have an Event Loop or Redirect on Fail? That would return a web page.

Bob
Tozai_X 27 Aug, 2014
Thank you Bob.
Yes you're right, i'm getting back empty page...

But why this form:

http://www.refermind.com/svil1/index.php?option=com_chronoforms&chronoform=start_training_1_ita

appears to be working correctly?

The PHP is the same, the results are different.

May I attach the form backup file? Can be useful?
GreyHead 27 Aug, 2014
Hi Tozai_X,

The backup isn’t very useful with Ajax problems as I don't have the database tables necessary to get the code to work. By all means email or PM me the site URL, the form name, and a SuperAdmin login and I'll take a quick look.

Bob
Tozai_X 28 Aug, 2014
I sent message.

Thank you.
GreyHead 30 Aug, 2014
Hi Tozai_X,

I fixed the problem in the first pair of drop-downs in the gestione_anagrafica_ita form.

You had an Event Loop action in the 'No Record Found' box of the DB Record Loader. What happened was that when no record was found the action tried to return the form that event was linked to and showed you a site page.

I replaced the Event Loop with a Custom Code action that returns a single option:
echo '=Selezionare Sport';


Bob
Tozai_X 31 Aug, 2014
1 Likes
Thanks a lot, Bob.

I bought you a coffee!!! πŸ˜€

Toz.
antjoom 24 Nov, 2014
hello,
it would be possible to have the complete file?

I am ready even to give an economic contribution
thanks so much

Antonio
Max_admin 25 Nov, 2014
Hi Antonio,

If you have v5 then there is a dynamic dropdown demo form included!

Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
antjoom 25 Nov, 2014
Hi Max,
i used the v5, bat the demo not have 3 dinamic dropdown

Regards
Antonio
Max_admin 08 Dec, 2014
Hi Antonio,

Sorry for the late answer.

Yes, but you can use the same idea.

Regards,
Max
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.