Welcome to the nuBuilder Forums!

Register and log in to access exclusive forums and content available only to registered users.

dependent dropdown in a subform

Questions related to customising nuBuilder Forte with JavaScript or PHP.
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

dependent dropdown in a subform

Unread post 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?
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: dependent dropdown in a subform

Unread post by kev1n »

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: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: dependent dropdown in a subform

Unread post by johan »

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

Johan
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: dependent dropdown in a subform

Unread post 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?
steven
Posts: 370
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 53 times
Been thanked: 52 times

Re: dependent dropdown in a subform

Unread post 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
A short post is a good post.
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: dependent dropdown in a subform

Unread post 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
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: dependent dropdown in a subform

Unread post by kev1n »

BTW:

gevangenis = prison
sectie = section
lokaal = room
steven
Posts: 370
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 53 times
Been thanked: 52 times

Re: dependent dropdown in a subform

Unread post 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.
You do not have the required permissions to view the files attached to this post.
A short post is a good post.
johan
Posts: 399
Joined: Sun Feb 27, 2011 11:16 am
Location: Belgium
Been thanked: 3 times

Re: dependent dropdown in a subform

Unread post 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?
steven
Posts: 370
Joined: Mon Jun 15, 2009 10:03 am
Has thanked: 53 times
Been thanked: 52 times

Re: dependent dropdown in a subform

Unread post 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
A short post is a good post.
Post Reply