Page 1 of 4

dependent dropdown in a subform

Posted: Fri Sep 10, 2021 11:26 am
by johan
Hi
How can I create a dependent dropdown in a subform?
sectie depents on gevangenis.
Selectie_322.png
My code in object select is

Code: Select all

SELECT distinct secties.sec_id, secties.sec_name FROM secties 
inner join gevangenis  on gevangenis.gev_id = secties.sec_gevangenis
where  secties.sec_gevangenis = '#res_gevangenis#' 
Sectie returns empty.

What am I doing wrong?

Re: dependent dropdown in a subform

Posted: Fri Sep 10, 2021 12:46 pm
by kev1n
Hi,

Try the attached nuform.js. Replace yours with the one from the attachment and then log in again into nuBuilder.

Re: dependent dropdown in a subform

Posted: Mon Sep 13, 2021 9:37 am
by johan
Kev1n
I've replaced nuForm.js but still the same result.

Johan

Re: dependent dropdown in a subform

Posted: Wed Sep 15, 2021 6:42 pm
by johan
Today I've updated my nuBuilder tot the latest version on github hoping that this should solve the problem.
I still don't get info in the diepending select.
Any idea?

Re: dependent dropdown in a subform

Posted: Thu Oct 07, 2021 12:30 am
by steven
johan,

Can you try to explain your problem a bit more.

What do you mean exactly when you say...
How can I create a dependent dropdown in a subform?
Are you wanting sectie fields to automatically be populated when the Form loads?
What is '#res_gevangenis#' ?

Steven

Re: dependent dropdown in a subform

Posted: Thu Oct 07, 2021 9:12 am
by johan
Steven
In my subform (first post in this subject) I have 3 dropdowns

gevangenis (res_gevangenis), sectie (res_sectie) and lokaal (res_lokaal)

First I make a choice of in "gevangenis". Then I want sectie to show only the sectie of that gevangenis, ...
That's why my select is

Code: Select all

SELECT distinct secties.sec_id, secties.sec_name FROM secties
inner join gevangenis  on gevangenis.gev_id = secties.sec_gevangenis
where  secties.sec_gevangenis = '#res_gevangenis#'
Where should be the value of the gevangis selected in this row of the subform.

Johan

Re: dependent dropdown in a subform

Posted: Thu Oct 07, 2021 9:48 am
by kev1n
BTW:

gevangenis = prison
sectie = section
lokaal = room

Re: dependent dropdown in a subform

Posted: Sat Oct 09, 2021 7:40 am
by steven
johan,

Each field in a subform also has a prefix (as underlined here)...
sf.PNG
So to use it as a Hash Cookie you would need to include that prefix (which really means you can't do it.)

The 2 alternatives are either use a Javascript array to empty then repopulate the second Select Object...

OR

Use a Lookup instead of a Select. This will allow the use of Hash Cookies but only from the main Edit Form (you may need to populate a hidden field before you launch the Lookup.


Steven.

Re: dependent dropdown in a subform

Posted: Sat Oct 09, 2021 8:49 am
by johan
Steven
Thanks for your reply. Seems like Javascript is the best solution. Only I don't know how it works.
Is there an example in the demo?

Re: dependent dropdown in a subform

Posted: Sun Oct 10, 2021 12:46 am
by steven
johan,

kev1n has explained to me...

gevangenis = prison
sectie = section
lokaal = room

How many sectie are there in total? (10 or hundreds)

Does every sectie have a unique name? If it does you can create a sectie and add its gevangenis. Then you can create a lookup that can display both sectie and gevangenis by just selecting sectie.

That would be easier and you only need to select 1 field, not 2.


Steven