dependent dropdown in a subform

Questions related to customising nuBuilder Forte with JavaScript or PHP.

dependent dropdown in a subform

Unread postby johan » Fri Sep 10, 2021 6:56 pm

Hi
How can I create a dependent dropdown in a subform?
sectie depents on gevangenis.
Selectie_322.png
Selectie_322.png (20.67 KiB) Viewed 370 times


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?
johan
 
Posts: 349
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: dependent dropdown in a subform

Unread postby kev1n » Fri Sep 10, 2021 8:16 pm

Hi,

Try the attached nuform.js. Replace yours with the one from the attachment and then log in again into nuBuilder.
Attachments
nuform.zip
(27.88 KiB) Downloaded 21 times
kev1n
nuBuilder Team
 
Posts: 2059
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: dependent dropdown in a subform

Unread postby johan » Mon Sep 13, 2021 5:07 pm

Kev1n
I've replaced nuForm.js but still the same result.

Johan
johan
 
Posts: 349
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: dependent dropdown in a subform

Unread postby johan » Thu Sep 16, 2021 2:12 am

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?
johan
 
Posts: 349
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: dependent dropdown in a subform

Unread postby steven » Thu Oct 07, 2021 8:00 am

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
steven
 
Posts: 150
Joined: Mon Jun 15, 2009 5:33 pm

Re: dependent dropdown in a subform

Unread postby johan » Thu Oct 07, 2021 4:42 pm

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
johan
 
Posts: 349
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: dependent dropdown in a subform

Unread postby kev1n » Thu Oct 07, 2021 5:18 pm

BTW:

gevangenis = prison
sectie = section
lokaal = room
kev1n
nuBuilder Team
 
Posts: 2059
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: dependent dropdown in a subform

Unread postby steven » Sat Oct 09, 2021 3:10 pm

johan,

Each field in a subform also has a prefix (as underlined here)...

sf.PNG
sf.PNG (67.54 KiB) Viewed 167 times


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.
steven
 
Posts: 150
Joined: Mon Jun 15, 2009 5:33 pm

Re: dependent dropdown in a subform

Unread postby johan » Sat Oct 09, 2021 4:19 pm

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?
johan
 
Posts: 349
Joined: Sun Feb 27, 2011 7:46 pm
Location: Belgium

Re: dependent dropdown in a subform

Unread postby steven » Sun Oct 10, 2021 8:16 am

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
steven
 
Posts: 150
Joined: Mon Jun 15, 2009 5:33 pm

Next

Return to Custom Code

Who is online

Users browsing this forum: No registered users and 2 guests

cron