Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Questions related to customising nuBuilder Forte with JavaScript or PHP.
johan
Posts: 422 Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times
Unread post
by johan » Fri Sep 10, 2021 11:26 am
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?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4416 Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:
Unread post
by kev1n » Fri Sep 10, 2021 12:46 pm
Hi,
Try the attached nuform.js. Replace yours with the one from the attachment and then log in again into nuBuilder.
You do not have the required permissions to view the files attached to this post.
johan
Posts: 422 Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times
Unread post
by johan » Mon Sep 13, 2021 9:37 am
Kev1n
I've replaced nuForm.js but still the same result.
Johan
johan
Posts: 422 Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times
Unread post
by johan » Wed Sep 15, 2021 6:42 pm
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?
steven
Posts: 379 Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 54 times
Been thanked: 52 times
Unread post
by steven » Thu Oct 07, 2021 12:30 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
A short post is a good post.
johan
Posts: 422 Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times
Unread post
by johan » Thu Oct 07, 2021 9:12 am
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
kev1n
nuBuilder Team
Posts: 4416 Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 74 times
Been thanked: 472 times
Contact:
Unread post
by kev1n » Thu Oct 07, 2021 9:48 am
BTW:
gevangenis = prison
sectie = section
lokaal = room
steven
Posts: 379 Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 54 times
Been thanked: 52 times
Unread post
by steven » Sat Oct 09, 2021 7:40 am
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.
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
johan
Posts: 422 Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times
Unread post
by johan » Sat Oct 09, 2021 8:49 am
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?
steven
Posts: 379 Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 54 times
Been thanked: 52 times
Unread post
by steven » Sun Oct 10, 2021 12:46 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
A short post is a good post.