Welcome to the nuBuilder Forums!

Join our community by registering and logging in.
As a member, you'll get access to exclusive forums, resources, and content available only to registered users.

Display weekday name in subgrid.

Questions related to using nuBuilder Forte.
Post Reply
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Display weekday name in subgrid.

Unread post by amit »

Hi guys,
I have a subgrid which contains dates in the first column. In the 2nd column I'd like to display the weekday (e.g. Monday) if the date is changed. How do I do that?
kev1n
nuBuilder Team
Posts: 4565
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 529 times
Contact:

Re: Display weekday name in subgrid.

Unread post by kev1n »

Hi,

Add an onchange event to your date field and paste this JavaScript into your form's Custom Code.

Code: Select all

function dayName(date) {
	var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
	return days[new Date(date).getDay()];
}

function dateChanged(event) {

	var id = event.target.id;
	var date = $('#' + String(id)).val();
	row = $('#' + String(id)).attr('data-nu-prefix').slice(-3);
	$("#sf_obj_id" + row + "sf_dayname").val(dayName(date)).change();

}
You do not have the required permissions to view the files attached to this post.
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Re: Display weekday name in subgrid.

Unread post by amit »

It doesn't work for me - no weekday is shown :(
kev1n
nuBuilder Team
Posts: 4565
Joined: Sun Oct 14, 2018 6:43 pm
Has thanked: 76 times
Been thanked: 529 times
Contact:

Re: Display weekday name in subgrid.

Unread post by kev1n »

The function must be passed a valid date, which can be parsed. Otherwise it must be converted before.
amit
Posts: 36
Joined: Sat Jun 02, 2018 1:26 pm

Re: Display weekday name in subgrid.

Unread post by amit »

That did the trick - thx kev1n :D
Post Reply