Buy Now
Sign in

Triple Dynamic Dropdown

Tozai_X , August 21 2014
Tozai_X 28
August 21 2014 #334940
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 63.3
    August 25 2014 #335188
    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
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    Tozai_X 28
    August 26 2014 #335234
    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 63.3
    August 27 2014 #335254
    Hi MT,

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

    Bob
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    Tozai_X 28
    August 27 2014 #335290
    Really?!?
    If I select "Seleziona Sport" on the first dropdown...

    Check the attachment.
    Triple.png
    Attachments
    Triple.png
    Triple.png
    (65.83 KiB)
    571 Downloads/Views
    GreyHead 63.3
    August 27 2014 #335292
    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
    Attachments
    2014-08-27_18-27-12.png
    2014-08-27_18-27-12.png
    (57.98 KiB)
    544 Downloads/Views
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    Tozai_X 28
    August 27 2014 #335297
    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 63.3
    August 27 2014 #335300
    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
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    Tozai_X 28
    August 28 2014 #335309
    I sent message.

    Thank you.
    GreyHead 63.3
    August 30 2014 #335431
    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
    ChronoForms technical support
    If you'd like to buy me a coffee or two, thank you very much
    Tozai_X 28
    August 31 2014 #335462
    1
    Thanks a lot, Bob.

    I bought you a coffee!!!

    Toz.
    A
    antjoom 4
    November 24 2014 #339504
    hello,
    it would be possible to have the complete file?

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

    Antonio
    admin 26.5
    November 25 2014 #339536
    Hi Antonio,

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

    Regards,
    Max
    Max
    If your main question got answered then please mark the answer using the button!
    Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
    A
    antjoom 4
    November 25 2014 #339555
    Hi Max,
    i used the v5, bat the demo not have 3 dinamic dropdown

    Regards
    Antonio
    admin 26.5
    December 08 2014 #340232
    Hi Antonio,

    Sorry for the late answer.

    Yes, but you can use the same idea.

    Regards,
    Max
    Max
    If your main question got answered then please mark the answer using the button!
    Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!