2012-03-31 4 views
0

함수 값을 확인하는 방법은 무엇입니까?

checkform이 참 또는 거짓 반환
<input type="button" value="Submit" onclick="checkform(form); someotherfunction();" 

이 함수는 형태로 사용이 코드를 고려하십시오.

checkform() 값이 false인지 확인한 다음 입력을 취소하면 someotherfunction()으로 전화를 걸 수 있으며 그 반대의 경우도 마찬가지입니다.

나는 그것을 상관없이에게 값을 반환하는 것 전혀 때문에, 내가 어떻게 그 다음 someotherfunction()를 호출 할 수 있도록 checkform()에 해당하면 확인할 수 있습니다 나던 호출 someotherfunction()

<input type="button" value="Submit" onclick="return checkform(form); someotherfunction();" 

를 시도?

checkform()의 값을 someothefunction() 안에 확인하고 싶지 않다면 <input 행을 체크인 할 수 있습니까?

답변

1

if : 동일한 메커니즘을 사용하지만 checkform에서 someotherfunction()를 호출보다이 완벽하게 작동하지 않을 경우

onclick="if(checkform(form)){someotherfunction();}" 
+2

또한 'onclick = "checkform (form) & someotherfunction();"을 할 수도 있습니다. " –

+0

당신과 당신의 환상적인 단락이 .../rabble – canon

+2

ify가 if 문을 사용했습니다! –

0

이 당신에게

<script> 
var formExist = true; 

function someotherfunction(){ 
    if(formExist){ 
     // do your stuff... 
    } 
} 
</script> 

<body> 
... 

<input type="button" value="Submit" onclick="formExist = checkform(form); someotherfunction();" /> 

... 
</body> 

도움이 될 것입니다(), 는 definetely 일 ...

관련 문제