Welcome to the nuBuilder Forums!

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

3 Iframes with different cookies

Questions related to customising nuBuilder Forte with JavaScript or PHP.
Post Reply
ernesttan1976
Posts: 51
Joined: Sat May 16, 2020 10:08 am

3 Iframes with different cookies

Unread post by ernesttan1976 »

Hi all,

I have 3 iframes opening the same browse/edit form.
There are 3 DISPLAY*** objects which run an SQL to show the statistic.
However it seems to be wrong and all showing the same result.
The variable is called #Project# is a cookie seems to be shared among all 3 iframes.
How do I separate into 3 different cookies, or otherwise?


Edit: *** sorry it's DISPLAY object, not SELECT object.
You do not have the required permissions to view the files attached to this post.
Last edited by ernesttan1976 on Mon Oct 12, 2020 8:27 am, edited 1 time in total.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: 3 Iframes with different cookies

Unread post by kev1n »

Retrieve the corresponding project in your getEmployeeInfo() function.

Code: Select all

function getEmployeeInfo(event) {

    var empId = $('#' + event.target.id).val();
    nuSetProperty('empId', empId);

    var prefix = $(event.target).attr('data-nu-prefix');
    nuSetProperty('prefix', prefix);
	
    var project = $(event.target).parent().find('#' + 'project').val();   // ----> replace 'project' with your project object ID 
    nuSetProperty('project', project);
	
    nuRunPHPHidden('getEmployeeInfo', 0)
}

In your PHP procedure, use the hash cookie #project# to retrieve the project.

PS: I presume that your questions is related to the other topic: https://forums.nubuilder.cloud/viewtopic.php?f=20&t=10580
ernesttan1976
Posts: 51
Joined: Sat May 16, 2020 10:08 am

Re: 3 Iframes with different cookies

Unread post by ernesttan1976 »

HI Kevin,

Sorry I was not clear.

What I mean is the Active Deployed Display Object uses an SQL like so.
SELECT Count(ActiveDeployed) FROM project_assignment WHERE project_code = '#project#'

#project# is the cookie which will be set when loading the project field.
When I refresh, the display object should show 3 different sets of statistics. but it shows as if there is only 1 cookie.
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: 3 Iframes with different cookies

Unread post by kev1n »

This seems to be a nuBuilder limitation. The hash cookie #project# exists only once for all 3 iframes.
And right now I can't think of an elegant solution. Maybe someone else?
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: 3 Iframes with different cookies

Unread post by Janusz »

Hi,
I just did similar try with 3 identical forms in the iframes on the same edit form - and did not observe any issue.
The hash cookies are separated between iframes.
Initially you can try to display hash cookie only like:
SELECT '#project#'
maybe there are some name conflicts, or ...
If you like nuBuilder, please leave a review on SourceForge
Janusz
nuBuilder Team
Posts: 506
Joined: Fri Dec 28, 2018 1:41 pm
Location: Krakow, Poland
Has thanked: 8 times
Been thanked: 18 times

Re: 3 Iframes with different cookies

Unread post by Janusz »

If you like nuBuilder, please leave a review on SourceForge
kev1n
nuBuilder Team
Posts: 4305
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: 3 Iframes with different cookies

Unread post by kev1n »

ernesttan1976 wrote:When I refresh, the display object should show 3 different sets of statistics. but it shows as if there is only 1 cookie.
Does the issue only occur when you refresh the form?
ernesttan1976
Posts: 51
Joined: Sat May 16, 2020 10:08 am

Re: 3 Iframes with different cookies

Unread post by ernesttan1976 »

Hi Kevin and Janusz,

Thank you for your great help.
From Janus' answer, Nubuilder is able to support multiple instances of the same iframe form with its cookies, even with the same name.

So I went back and realized I have 1 cookie on the launch form with 'Project' and another cookie on the iframe with 'Project'. that's why it conflicted.
My bad!
I changed the iframe cookie to 'Project2' and it worked!

Thanks guys!
You do not have the required permissions to view the files attached to this post.
admin
Site Admin
Posts: 2815
Joined: Mon Jun 15, 2009 2:23 am
Been thanked: 25 times

Re: 3 Iframes with different cookies

Unread post by admin »

.
Post Reply