Forums

Problem with dropdown update

ilmagowalter 10 Feb, 2016
Hi, i have this form
http://www.screencast.com/t/4tWqqai5bpjM

the dropdown "Sede Installazione" depend from "Cliente" ( populated with DB Read onload )
the dropdownlist "Video Disponbili" depend from "Sede Installazione"
the dropdownlist "Video Associati" depend from "Sede Installazione"

when i select a value on "Cliente", i can see the values on "Sede Installazione" but not in "Video Disponibili" and "Video Associati"

to can see the value in "Video Disponibili" and "Video Associati" i have to change value on dropdown "Sede Installazione"...like that for the system is need to select manually

how can i fix ?
GreyHead 11 Feb, 2016
Hi ilmagowalter,

I'm not completely clear how this works or exactly what the problem is.

If you change Cliente than you have to add custom JavaScript to update the other three drop-downs. ChronoForms does not do this for you automatically. It might be simpler to make this a two-page form with the Cliente dropdown on page 1 and the other three on page 2 then you can set the required drop-down options in the On Load event for the second page.

Bob
ilmagowalter 11 Feb, 2016
this is the event configuration of id_cliente
http://www.screencast.com/t/frgA1AWJp

this is the event configuration of id_sede
http://www.screencast.com/t/heBkbx0lKMl

and this is the setup
http://www.screencast.com/t/HjVjdmBXC

this event works
the only problem is that the events on id_sede don't start when cliente is changed...
in fact when after cliente changed, i change a value of sede the events start and other 2 dropdown are populated

seems that when cliente is changed the system doesn't catch the event on id_sede...like that we don't have value selected on idsede...
is some code that i can add to force to select element in dropdown id_sede ?
ilmagowalter 12 Feb, 2016
another question
is possible force the execute of event "carica_video_disponibili" and "carica_video_associati" ?
( i tried an event loop after custom code of carica_id_sede but don't work )
GreyHead 12 Feb, 2016
Hi ilmagowalter,

If you change Cliente than you have to add custom JavaScript to update the other three drop-downs. ChronoForms does not do this for you automatically.

Bob
ilmagowalter 12 Feb, 2016
I am not very practical with javascript but i will try (obv i accept suggest🙂 )

another question
i tried to ask this form by link adding 2 parameter
ID_CLIENTE and ID_SEDE ( the fields in form have the same name of parameter )
i can see that ID_CLIENTE is correct but ID_SEDE no...maybe because ajax event on cliente "overwrite" the parameter ?
GreyHead 12 Feb, 2016
Hi ilmagowalter,

Normally a parameter in a URL will set the corresponding drop-down - I'm afraid that I don't know exactly what happens when you have dynamic options set for the drop-down as well. It may be that you need to set the value using JavaScript after the form has loaded. It depends on when the options are set.

Bob
ilmagowalter 12 Feb, 2016
you mean something like this

function selectlOption(id)
{
    var elem=document.getElementById(id);
    var i=0;
    for(i=0 ; i<elem.options.length ; i++)
    {
        if elem.options[i].value = id_sede // how refer this ?{
         elem.options[i].selected=true;
         }
    }
    return true;
}

after html render ?
GreyHead 12 Feb, 2016
Hi ilmagowalter,

The JavaScript needs to be in a Load JavaScript action before the HTML (Render form) action. The value of id_sede can either be passed as a hidden input in the form, or as a JavaScript variable - either way will work, the JS variable is probably neater.

Bob
ilmagowalter 13 Feb, 2016
can you make me a complete example of this ? i will pay you a coffee😉
This topic is locked and no more replies can be posted.