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?
Welcome to the nuBuilder Forums!
Register and log in to access exclusive forums and content available only to registered users.
Register and log in to access exclusive forums and content available only to registered users.
Display weekday name in subgrid.
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Display weekday name in subgrid.
Hi,
Add an onchange event to your date field and paste this JavaScript into your form's Custom Code.
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.
-
- Posts: 36
- Joined: Sat Jun 02, 2018 1:26 pm
-
- nuBuilder Team
- Posts: 4307
- Joined: Sun Oct 14, 2018 6:43 pm
- Has thanked: 71 times
- Been thanked: 448 times
- Contact:
Re: Display weekday name in subgrid.
The function must be passed a valid date, which can be parsed. Otherwise it must be converted before.
-
- Posts: 36
- Joined: Sat Jun 02, 2018 1:26 pm