3 Iframes with different cookies

Questions related to customising nuBuilder Forte with Javascript or PHP.

3 Iframes with different cookies

Postby ernesttan1976 » Sat Oct 10, 2020 2:17 pm

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.
Attachments
Screenshot.jpg
Screenshot.jpg (490.48 KiB) Viewed 283 times
Last edited by ernesttan1976 on Mon Oct 12, 2020 3:57 pm, edited 1 time in total.
ernesttan1976
 
Posts: 30
Joined: Sat May 16, 2020 5:38 pm

Re: 3 Iframes with different cookies

Postby kev1n » Sat Oct 10, 2020 5:56 pm

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: viewtopic.php?f=20&t=10580
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: 3 Iframes with different cookies

Postby ernesttan1976 » Mon Oct 12, 2020 3:16 pm

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.
ernesttan1976
 
Posts: 30
Joined: Sat May 16, 2020 5:38 pm

Re: 3 Iframes with different cookies

Postby kev1n » Mon Oct 12, 2020 11:45 pm

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?
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: 3 Iframes with different cookies

Postby Janusz » Tue Oct 13, 2020 1:04 am

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
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: 3 Iframes with different cookies

Postby Janusz » Tue Oct 13, 2020 1:46 am

If you like nuBuilder, please leave a review on SourceForge
Janusz
 
Posts: 399
Joined: Fri Dec 28, 2018 10:11 pm
Location: Krakow, Poland

Re: 3 Iframes with different cookies

Postby kev1n » Tue Oct 13, 2020 5:23 am

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?
If you like nuBuilder, please leave a review on SourceForge

nuBuilder Code Library (82)
Installation Guides
Updating nuBuilder

Join Discord to talk about nuBuilder!
kev1n
 
Posts: 1084
Joined: Mon Oct 15, 2018 2:13 am

Re: 3 Iframes with different cookies

Postby ernesttan1976 » Mon Oct 19, 2020 11:47 am

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!
Attachments
screenshot (2).jpg
screenshot (2).jpg (311.51 KiB) Viewed 218 times
ernesttan1976
 
Posts: 30
Joined: Sat May 16, 2020 5:38 pm

Re: 3 Iframes with different cookies

Postby admin » Wed Oct 21, 2020 9:15 am

.
admin
Site Admin
 
Posts: 3402
Joined: Mon Jun 15, 2009 9:53 am


Return to Custom Code



cron