如果不运行则嵌套
Nested If Not Running Else
我正在尝试评估一些事情。我从第一个父if语句和嵌套的if/else粘贴代码。由于某种原因,当满足父元素的条件时,它总是使用嵌套的if而不是去else。即使它不满足if条件,它仍然运行这段代码。
var setmeow = new Date();
var meow = nlapiDateToString(setmeow);
if(!Result[i].getValue('custcol_ram_billing_end_date') ){
var edpb = Result[i].getValue('custcolram_last_rental_billed')
if(edpb != null || edpb != ' ') {
var daysbetwenced = days_between(nlapiStringToDate(Result[i].getValue('custcol_ram_billing_start_date')), setmeow);
record.setCurrentLineItemValue('item', 'quantity', daysbetwenced+1);
//record.setCurrentLineItemValue('item', 'custcol_ram_billing_start_date', Result[i].getValue('custcol_ram_billing_start_date'));
record.setCurrentLineItemValue('item', 'custcol_ram_billing_end_date', meow);
record.setCurrentLineItemValue('item', 'custcolram_last_rental_billed', meow);
} else {
var daysbetweennoend = days_between(nlapiStringToDate(Result[i].getValue('custcolram_last_rental_billed')), setmeow);
record.setCurrentLineItemValue('item', 'quantity', daysbetweennoend+1);
record.setCurrentLineItemValue('item', 'custcol_ram_billing_start_date', Result[i].getValue('custcolram_last_rental_billed'));
record.setCurrentLineItemValue('item', 'custcol_ram_billing_end_date', meow);
record.setCurrentLineItemValue('item', 'custcolram_last_rental_billed', meow);
}
}
请记住,||
是逻辑或运算符,
if(edpb != null || edpb != ' ')
无论edpb
是什么,总是不等于null
或不等于' '
。也就是说,它既不是null
也不是' '
,或者它将是其中之一而不是另一个。
如果edpb
不是null
或' '
,可能您真正想要的是执行if
部分,这将是:
if (edpb != null && edpb != ' ')
相关文章:
- 用嵌套函数和默认函数定义函数
- 如何在ReactJS JSX中执行嵌套的if-else语句
- 可以简化嵌套的延迟Q Promises解析吗
- 我需要在单击时运行两个函数.即使嵌套在一起,我也无法让它们都工作
- for循环中的嵌套promise未按预期运行
- 如何将嵌套承诺与Q连锁?我可以'Don’我不能让它们按正确的顺序运行
- 如何运行嵌套的 JavaScript 函数
- 从嵌套的 jquery 对话框运行服务器端方法
- 简单嵌套的 setTimeout() 只运行一次 (JavaScript)
- 我可以在change()函数中为同一个$('element.class')运行嵌套的$('!ele
- 在嵌套的For循环中运行Eval
- 淘汰嵌套组件:$(document).ready() ..在加载嵌套组件之前运行
- 如何在javascript中自定义嵌套对象和数组中运行函数
- Greensock嵌套的时间线没有按照预期运行
- 如何递归调用/运行jQuery嵌套模板
- ruby on rails-如何使用javascript运行多个嵌套调用
- 在Sharepoint中运行嵌套查询
- 嵌套的 jQuery 每个语句在第一个语句完成后运行
- NodeJs MongoDB嵌套查询-同步运行回调
- 如果不运行则嵌套