2011-11-30 4 views
3

aspx 페이지의 HTML 단추 클릭 이벤트와 페이지 코드 숨김의 서버 메서드에 대한 JavaScript 함수가 있습니다. 사용자가 HTML 버튼을 클릭하면 처리되고 버튼에 대답이 표시됩니다.업데이트 단추 레이블

버튼 레이블을 AJAX를 사용하는 것처럼 업데이트하려면 어떻게해야합니까?

업데이트를 어딘가에 설정하려고하면 페이지가 버튼을 업데이트하지 않습니다. 텍스트 상자 업데이트가 제대로 작동합니다. 아래 코드에서 볼 수 있듯이 btnDivide에는 현재 "Get Weather"라는 설정 값이 있지만 처리가 완료되면 변경해야합니다.

<script type="text/javascript"> 
<![CDATA[ 

// This function creates an asynchronous call to the service 
function makeCall(operation){ 
    var n1 = document.getElementById("num1").value; 
    var n2 = document.getElementById("num2").value; 


    // If user filled out these fields, call the service 
    if(n1 && n2){ 

     // Instantiate a service proxy 
     var proxy = new Service(); 

     // Call correct operation on vf cproxy  
     switch(operation){ 

      case "gridOne": 
proxy.Calculate(AjaxService.Operation.getWeather,n1,n2,  
onSuccess, onFail, null); 
       btnDivide.value = "TestNewValue"; 

       break; 
      case "gridTwo": 
******* 
</script> 

<style type="text/css"> 
    #result 
    { 
     width: 1010px; 
    } 
</style> 

</head> 
<body> 
<h1>Ajax TicTacToe</h1> 
<p>Major City: <input type="text" id="num1" onclick="return 
num1_onclick()" /></p> 
<p>Country: <input type="text" id="num2" onclick="return num2_onclick()" 
/></p> 
&nbsp; 
<br /> 
<input id="btnDivide" type="button" onclick="return makeCall('gridOne');" 
    value="Get Weather" /> 

답변

0
function onSuccess(mathResult){ 
    document.getElementById("result").value = mathResult; 
    document.getElementById("btnDivide").value = "test"; 

} 
관련 문제