如何设置 javascript 计算函数等待它在另一个字段中看到值
how to set a javascript calculate function to wait until it sees a value in another field
我有一个函数可以计算(添加)其他 2 个字段的值并在第三个字段中显示结果。这非常有效。但是,我现在需要这个计算函数 "wait" 直到它看到一个值填充在一个单独的日期字段中。一旦这个日期字段有一个值,那么计算函数就可以显示结果。请参阅下面的当前计算函数。
感谢您提供的任何帮助。
function Calculate() {
var item1 = Xrm.Page.getAttribute("new_step1amount").getValue();
if (item1 == null) {
item1 = 0;
}
var item2 = Xrm.Page.getAttribute("new_step2amount").getValue();
if (item2 == null) {
item2 = 0;
}
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1 + item2);
}
伪代码如下:
if(dateFieldHasValue)
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1 + item2);
}
只需调用日期字段的函数 onchange
...
我有一个函数可以计算(添加)其他 2 个字段的值并在第三个字段中显示结果。这非常有效。但是,我现在需要这个计算函数 "wait" 直到它看到一个值填充在一个单独的日期字段中。一旦这个日期字段有一个值,那么计算函数就可以显示结果。请参阅下面的当前计算函数。
感谢您提供的任何帮助。
function Calculate() {
var item1 = Xrm.Page.getAttribute("new_step1amount").getValue();
if (item1 == null) {
item1 = 0;
}
var item2 = Xrm.Page.getAttribute("new_step2amount").getValue();
if (item2 == null) {
item2 = 0;
}
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1 + item2);
}
伪代码如下:
if(dateFieldHasValue)
{
Xrm.Page.getAttribute("new_totalamountcollected").setValue(item1 + item2);
}
只需调用日期字段的函数 onchange
...