2015-02-06 3 views
-1

경고 상자에 두 가지 다른 사항을 확인하려고하는 경우, 명세서. 첫 번째는 사용자가 예 버튼을 누르고 두 번째는 페이지의 사용자 입력 값입니다. 아래 코드를 참조하십시오. 나는 아직도 아주 초록색이다. 어떤 도움이라도 대단히 감사 할 것이다.명세서 및 조건

var cMsg = "You are about to reset this page!"; 
cMsg += "\n\nDo you want to continue?"; 

var nRtn = app.alert(cMsg,2,2,"Question Alert Box"); 
if(nRtn == 4) && (getField("MV").value == 5) 
{ 
////// do this 

} 
else if(nRtn == 4) && (getField("MV").value == 6) 
{ 
/////then do this 
} 
else if(nRtn == 4) && (getField("MV").value == 7) 
{ 
/////then do this 
} 

} 
else if(nRtn == 3) 
{ 
console.println("Abort the submit operation"); 
} 
else 
{ //Unknown Response 
console.println("The Response Was somthing other than Yes/No: " + nRtn); 
} 
+1

무엇이 질문입니까? – Teemu

+0

구문이 잘못된 경우 먼저 if (condition) .... if ((nRtn == 4) && (getField ("MV"). 값 == 5))를 사용하십시오. – Satpal

+0

@Satpal That 's 내가 뭘 찾고 있었는지 ... 고마워. –

답변

0

if...else 구문이 잘못되었습니다. "nRtn"// 값을 : 올바른 구문

if (condition) 
    statement1 
[else 
    statement2] 

를 사용하여 올바른 구문

if (nRtn == 4 && getField("MV").value == 5) { 
    ////// do this  
} else if (nRtn == 4 && getField("MV").value == 6) { 
    /////then do this 
} else if (nRtn == 4 && getField("MV").value == 7) { 
    /////then do this 
} else if (nRtn == 3) { 
    console.println("Abort the submit operation"); 
} else { //Unknown Response 
    console.println("The Response Was somthing other than Yes/No: " + nRtn); 
} 

대신

if (nRtn == 4) && (getField("MV").value == 5) { 
    ////// do this 

} else if (nRtn == 4) && (getField("MV").value == 6) { 
    /////then do this 
} else if (nRtn == 4) && (getField("MV").value == 7) { 
    /////then do this 
} <=== Remove this 

} else if (nRtn == 3) { 
    console.println("Abort the submit operation"); 
} else { //Unknown Response 
    console.println("The Response Was somthing other than Yes/No: " + nRtn); 
} 
0

당신은 두 개의 서로 다른 조건을 평가하기 위해 노력하고있다 app.alert에서 반환되었습니다 (cMsg, 2,2, "Question Alert Box"). 및 : getField ("MV"). 값입니다.

그러나 컴파일러는 중괄호가 끝나기 때문에 첫 번째 조건 만 처리합니다. 하나의 중괄호 안에 모든 조건을 동봉해야합니다. 관습에 따라 개별 조건은 주 브레이스 내에서 별도의 브레이스에 있어야합니다. 올바른 방법은 다음과 같아야합니다.

if ((nRtn == 4) && (getField("MV").value == 5)) 
//notice the initial if ((and terminating)) 
//You could have 3 conditions as follows 
// if (((condition1) && (condition2)) && (condition3))) 
{ 
////// do this 

} 
else if((nRtn == 4) && (getField("MV").value == 6)) 
{ 
/////then do this 
} 
else if((nRtn == 4) && (getField("MV").value == 7)) 
{ 
/////then do this 
} 

} 
else if(nRtn == 3) 
{ 
console.println("Abort the submit operation"); 
} 
else 
{ //Unknown Response 
console.println("The Response Was somthing other than Yes/No: " + nRtn); 
}