Page 1 of 1

passing hash cookie values

Posted: Mon Apr 19, 2021 10:58 pm
by GlenMcCabe
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

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 7:59 am
by kev1n
Try using a global Hash Cookie by passing true as 3rd parameter:

Code: Select all

nuSetProperty('start_date',y, true);

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 8:58 am
by GlenMcCabe
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

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 9:16 am
by kev1n
Replace / with -

Code: Select all

var y =$(this).val().replaceAll('/','-');
nuSetProperty('start_date',y, true);

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 9:54 am
by GlenMcCabe
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 ?

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 10:10 am
by kev1n
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

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 10:40 am
by GlenMcCabe
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.

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 10:55 am
by kev1n
$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#";

Re: passing hash cookie values

Posted: Tue Apr 20, 2021 11:17 am
by GlenMcCabe
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