使用JSP中的会话按下按钮

时间:2015-09-02 06:33:14

标签: javascript jsp

我编写了截图来从MySQL数据库中获取数据。

enter image description here

我添加了JavaScript代码,点击接受按钮接受,点击拒绝按钮拒绝

我想在用户再次打开页面时将这些选择保留在网页中。

如何实施此功能?

    <script>
       function clickabtn(){
           var el = document.getElementById('btnacc');
           if(el.textContent=="Accept"){
             el.textContent="Accepted";  
           }else{
               el.textContent="Accept";
           }
       }
   </script>

   <script>
       function clickdbtn(){
           var el = document.getElementById('btnde');
           if(el.textContent=="Decline"){
             el.textContent="Declined";  
           }else{
               el.textContent="Decline";
           }
       }
   </script>

1 个答案:

答案 0 :(得分:0)

嘿,只需将值设置为按钮

<script>
   function clickabtn(){
       var el = document.getElementById('btnacc');
       if(el.value == "Accept"){
         el.value = "Accepted";  
       }else{
           el.value = "Accept";
       }
   }
</script>

<script>
   function clickdbtn(){
       var el = document.getElementById('btnde');
       if(el.value == "Decline"){
         el.value = "Declined";  
       }else{
           el.value = "Decline";
       }
   }
</script>