2016-06-21 2 views
0

'리셋'버튼을 클릭하면 다른 버튼의 값이 변경됩니다. document.getelementbyid 속성을 사용하려고했지만 작동하지 않는 것 같습니다. 누군가 이것을 구현해야하는 방법을 알고 있습니까?문서 ID로 자바 값 설정

function reset() { 
    stop(); 
    x.reset(); 
    update(); 
    opnieuw = setTimeout(function(){ 
    document.getElementById("scherm3").style.display = "block"; 
    document.getElementById("scherm2.2").style.visibility = "hidden"; 
    }, 10000);  
    clearTimeout(timeOut); 
    clearTimeout(timeOutElse); 
    document.getElementById("buttontimer").value = "Start"; 
} 

setTimeout(start, 5000); 

function toggleTimer(event) { 
if (isTimerStarted) { 
    stop(); 
    event.target.value = 'Start'; 
    timeOut = setTimeout(function(){ 
    document.getElementById("scherm4").style.visibility = "visible"; 
    document.getElementById("scherm2.2").style.visibility = "hidden"; 
    }, 4000) 
    clearTimeout(opnieuw); 
    clearTimeout(timeOutElse); 
    } 
    else { 
    start(); 
    event.target.value = 'Stop'; 
    timeOutElse = setTimeout(function(){ 
    document.getElementById("scherm3").style.display = "block"; 
    document.getElementById("scherm2.2").style.visibility = "hidden"; 
    }, 8000) 
      clearTimeout(timeOut); 
    clearTimeout(opnieuw); 
    } 
} 

및 HTML : 당신은 아마 그냥 단순히 "시작"을함으로써 간단하게 코드를 만들어 별도로, "중지"버튼을, 그냥 보여줄 수

<div id="button1"><input type="button" value="Stop" onclick="toggleTimer(event); clicks5times();" id="buttontimer"></div>  
     <input type="button" value="Opnieuw" onclick="reset()" class="button2" id="opnieuw"> 
+3

그리고 html은 무엇입니까? – everton

+1

결코 호출되지 않는 재설정 함수, 정의되지 않은 시작 함수의 setTimeout 및 절대로 호출되지 않는 toggleTimer 함수가 있습니다. 보유하고있는 모든 것을 게시하고 그것이하고 있지 않은 일을 원하는대로 설명하면 유용한 해답을 얻을 수 있습니다. –

+0

@EvertonAgner 내 게시물을 편집합니다! – annaneedshelp

답변

1

/를위한 올바른 버튼을 숨길 현재 상황. "재설정"버튼을 표시하여 이미이 작업을 수행하고 있습니다. 그냥 "Stop"버튼으로 만드십시오. "시작"을 클릭하면 "시작"버튼이 숨겨지고 "중지"버튼이 표시됩니다. "중지"를 클릭하면 "중지"가 숨겨지고 "시작"이 표시됩니다. 전역 불린을 사용하여 상태를 추적하고 "Stop"버튼을 "Pause"버튼처럼 동작하게하고 타이머를 다시 0으로 설정하는 추가 "Reset"버튼을 표시 할 수도 있습니다. 성취하려고 노력하고있다.

+1

감사합니다! – annaneedshelp