-2

I have to save record depend on the user response either yes or no , in java script i need confirm box with yes and no button. If i press save button all records should be Save, other wise focus on particular control like textbox.

4

1 回答 1

0
   <button onclick="myFunction()">Try it</button> 
       <p id="demo"></p>
       <script type="text/javascript">
          function myFunction(){
             var x;
             var r=confirm("Press a button!");
             if (r==true){
                 x="You pressed OK!";
             }
             else{
                 x="You pressed Cancel!";
             }
             document.getElementById("demo").innerHTML=x;
         }
      </script>

您可以使用默认值,例如 ok 或 cancel,而不是 yes 或 no。

于 2012-06-05T05:11:56.323 回答