Welcome to the nuBuilder Forums!

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

passing hash cookie values

Questions related to using nuBuilder Forte.
Post Reply
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

passing hash cookie values

Unread post 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
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: passing hash cookie values

Unread post by kev1n »

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

Code: Select all

nuSetProperty('start_date',y, true);
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: passing hash cookie values

Unread post 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
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: passing hash cookie values

Unread post by kev1n »

Replace / with -

Code: Select all

var y =$(this).val().replaceAll('/','-');
nuSetProperty('start_date',y, true);
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: passing hash cookie values

Unread post 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 ?
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: passing hash cookie values

Unread post 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
You do not have the required permissions to view the files attached to this post.
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: passing hash cookie values

Unread post 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.
You do not have the required permissions to view the files attached to this post.
kev1n
nuBuilder Team
Posts: 4304
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 71 times
Been thanked: 445 times
Contact:

Re: passing hash cookie values

Unread post 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#";
GlenMcCabe
Posts: 114
Joined: Sun Sep 29, 2019 12:40 pm

Re: passing hash cookie values

Unread post 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
Post Reply