passing hash cookie values

Questions related to using nuBuilder Forte.

passing hash cookie values

Unread postby GlenMcCabe » Tue Apr 20, 2021 6:28 am

I have 2 inputs on a form start_date and end_date. They are to be used to change the select SQL on the before edit PHP of the form

onchange for start_date which is a nudate format yyyy/mm/dd

var y =$(this) val(0);
nuSetProperty('start_date',y);


onchange for end_date which is a nudate format yyyy/mm/dd

var z =$(this) val(0);
nuSetProperty('end_date',z);

At the start of before edit I have

$start_date=#start_date#;

$end_date=#end_date#;

If I debug the dates I get nothing.

Am I doing something obviously wrong?

How do I check the values held in y and start_date in the onchange for start_date?

Many thanks
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm

Re: passing hash cookie values

Unread postby kev1n » Tue Apr 20, 2021 3:29 pm

Try using a global Hash Cookie by passing true as 3rd parameter:

Code: Select all
nuSetProperty('start_date',y, true);
kev1n
nuBuilder Team
 
Posts: 1705
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: passing hash cookie values

Unread postby GlenMcCabe » Tue Apr 20, 2021 4:28 pm

Thanks Kevin. Tried that and no difference.

My input is a nudate yyyy-mm-dd. I am using

onchange for start_date which is a nudate format yyyy/mm/dd

var y =$(this) val(0);
nuSetProperty('start_date',y);

For example. I use the selector and choose 2021-01-01
How do I see the value of y before the nuSetProperty? Is y held as an internal date format? Is is held as a string 2021-01-01?
How do I see the value of hash cookie start-date ?

In my Before Edit I need to end up with a string '2021-01-01' to make the WHERE element of my SQL work. Should I manipulate the hash cookie in the js element or in the PHP element?

If I use Date-time local can I create the hash cookie to only use the YYYY MM DD elements?

I have been trying all of these but I just do not seem to end up with anything in my hash cookie. I will keep trying
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm

Re: passing hash cookie values

Unread postby kev1n » Tue Apr 20, 2021 4:46 pm

Replace / with -

Code: Select all
var y =$(this).val().replaceAll('/','-');
nuSetProperty('start_date',y, true);
kev1n
nuBuilder Team
 
Posts: 1705
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: passing hash cookie values

Unread postby GlenMcCabe » Tue Apr 20, 2021 5:24 pm

Kevin - tried this. I am now getting something when I debug.

I choose 2021-01-01 on my input.

In Before edit I debug the variable $sd which is set by $sd=#start_date#

Debug value 2019

Is there a problem with date format, UTC / local ?
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm

Re: passing hash cookie values

Unread postby kev1n » Tue Apr 20, 2021 5:40 pm

I think I don't fully understand your setup.

I tested it with an input (format yyyy-mm-dd) and set the hash cookie when the onblur event occurs.
Then in Before Browse I retrieve its value and then in the nuDebug Results I see the date I entered.

You can check it out in our test platform:
https://test.nubuilder.cloud/index.php?u=test&p=nutest
Attachments
hk.jpg
hk.jpg (57.77 KiB) Viewed 84 times
onblur.jpg
onblur.jpg (78.18 KiB) Viewed 84 times
kev1n
nuBuilder Team
 
Posts: 1705
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: passing hash cookie values

Unread postby GlenMcCabe » Tue Apr 20, 2021 6:10 pm

Kevin

Attached is my system form.

I use YYYY-MM-DD so I probably don't need the replace. It isn't doing any harm.
Attachments
before edit.png
before edit.png (78.45 KiB) Viewed 80 times
onclick.png
onclick.png (80.2 KiB) Viewed 80 times
input screen.png
input screen.png (67.27 KiB) Viewed 80 times
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm

Re: passing hash cookie values

Unread postby kev1n » Tue Apr 20, 2021 6:25 pm

$sd = #end_date#;
is supposed to be

Code: Select all
$sd = "#start_date#";


Use double quotes:

Code: Select all
$sd = "#start_date#";
$ed = "#end_date#";
kev1n
nuBuilder Team
 
Posts: 1705
Joined: Mon Oct 15, 2018 2:13 am
nuBuilder Version: 4.5

Re: passing hash cookie values

Unread postby GlenMcCabe » Tue Apr 20, 2021 6:47 pm

Kevin

I'm almost there now. I will tidy it up and if I have problems I will post again.

Many thanks for your help and if you are talking to Janusz thank him for me and wish him all well from me.

Glen
GlenMcCabe
 
Posts: 87
Joined: Sun Sep 29, 2019 8:10 pm


Return to General

Who is online

Users browsing this forum: No registered users and 14 guests