Thắng Trương
Bạn có muốn phản ứng với tin nhắn này? Vui lòng đăng ký diễn đàn trong một vài cú nhấp chuột hoặc đăng nhập để tiếp tục.

Go down
avatar
Admin
Admin
Tổng số bài gửi : 1562
Join date : 20/05/2018
https://thangcrm2.forumvi.com

[Javascript] Nhập ngày tháng năm sinh xuất tuổi Empty [Javascript] Nhập ngày tháng năm sinh xuất tuổi

Sun May 20, 2018 4:35 pm
Code:

//Khi Field ngaysinh onChange()
function myFunction() {

    //Lấy dữ liệu thời gian hiện tại
    var getYearCurrent = new Date().getFullYear();
    var getMonthCurrent = new Date().getMonth();
    var getDateCurrent = new Date().getDate();

    //Lấy dữ liệu thời gian ngày sinh
    var getYearBirth = window.parent.Xrm.Page.getAttribute("ngaysinh").getValue().getFullYear();
    var getMonthBirth = window.parent.Xrm.Page.getAttribute("ngaysinh").getValue().getMonth();
    var getDateBirth = window.parent.Xrm.Page.getAttribute("ngaysinh").getValue().getDate();

    //Tính tuổi
    var Age = getYearCurrent - getYearBirth;
    if (getMonthCurrent > getMonthBirth)
    {
        Age = Age + 1;
    }
    else if (getMonthCurrent == getMonthBirth)
    {
        if (getDateCurrent >= getDateBirth)
        {
            Age = Age + 1;
        }
    }
    Age = Age - 1;
    window.parent.Xrm.Page.getAttribute("tuoi").setValue(Age);
}

//Khi Form onLoad()
function blockAge() {
    window.parent.Xrm.Page.getControl("tuoi").setDisabled(true);
}
Về Đầu Trang
Permissions in this forum:
Bạn không có quyền trả lời bài viết