Page 1 of 1

3 Iframes with different cookies

Posted: Sat Oct 10, 2020 6:47 am
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.

Re: 3 Iframes with different cookies

Posted: Sat Oct 10, 2020 10:26 am
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

Re: 3 Iframes with different cookies

Posted: Mon Oct 12, 2020 7:46 am
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.

Re: 3 Iframes with different cookies

Posted: Mon Oct 12, 2020 4:15 pm
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?

Re: 3 Iframes with different cookies

Posted: Mon Oct 12, 2020 5:34 pm
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 ...

Re: 3 Iframes with different cookies

Posted: Mon Oct 12, 2020 6:16 pm
by Janusz

Re: 3 Iframes with different cookies

Posted: Mon Oct 12, 2020 9:53 pm
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?

Re: 3 Iframes with different cookies

Posted: Mon Oct 19, 2020 4:17 am
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!

Re: 3 Iframes with different cookies

Posted: Wed Oct 21, 2020 1:45 am
by admin
.