2012-07-25 6 views
0

작동하지 않는 경우 여기에 내 코드입니다 :문은 어떤 이유로

alert ("Current: " + crmForm.all.new_currentdate.DataValue); 
alert ("Previous value: " + crmForm.all.new_date.DataValue); 

if(crmForm.all.new_currentdate.DataValue != crmForm.all.new_date.DataValue) 
{ 
    crmForm.all.new_otherValue.DataValue = null; 
    alert("Nulling other value"); 
} 

당신이 볼 수 있듯이, 나는 처음에 값을 확인하는 경고에 넣어 한, 그들은 동일합니다. 그러나 여전히 IF 문으로 넘어 가고 있으며 세 번째 경고 (다른 값을 무시)도 표시됩니다. 어떤 아이디어? 이것은 MS Dynamics CRM에 있습니다.

감사

문 오히려 이상 할 수있는 경우 unitiatated 자바 스크립트에 대한
+1

from here? 만약 그들이 문자열이라면, 아마도 그들 중 하나는 끝에 공백을 가지고 있습니다. – oezi

+3

'alert' 상자에서 그것을 검사 할 때, 여러분은 그것들을 볼 때만 그들의 평등을 확인할 수 있습니다. 그래서 본질적으로 그것들은 단지 같거나 특히 문자열 표현이 동일하게 보이기 때문입니다 (문자열로 연결하기 때문에 문자열로 변환됩니다). 다음을 시도해보고 결과를 확인하십시오. alert (crmForm.all.new_currentdate.DataValue == crmForm.all.new_data.DataValue) –

+0

비교하기 전에 두 값에'trim()'을 호출하면 끝 부분의 공백을 방지 할 수 있습니다. 이. –

답변

0
console.log(true + 1); // outputs 2 
console.log(true == 1); // outputs true 
console.log(true === 1); // outputs false. true is not the number 1. 
console.log(false + 1); // outputs 1 
console.log(false == 0); // outputs true 
console.log(false === 0); // outputs false. false is not the number 0. 

, 그`DataValue`있는 데이터의 유형

+2

'0.1 + 0.2 == 0.3 // false' -> OPs 문제는 거의 모든 것이 될 수 있습니다 ... – Christoph

관련 문제