在PHP中单击后如何禁用按钮 [英] how to disable a button after click in php

查看:77
本文介绍了在PHP中单击后如何禁用按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<td><a class="edit" title="Accept" href="javascript:void()" onclick="get_accept(''<?php echo $data[''id''];?>'');" >Accept</a></td>




第一次单击后,我如何从此接受"按钮的页面禁用或消失,因为我正在从该按钮发送时间戳值,并且当用户在一段时间后单击此按钮时,它将获得新的时间戳.




how can i disable or disappear from the page this Accept button after first click because i am sending a timestamp value from this button and when a user click this button after some time then it will get new timestamp.
please help.

推荐答案

data [''id''];?>'');> Accept</a></td>
data[''id''];?>'');" >Accept</a></td>




第一次单击后,我如何从此接受"按钮的页面禁用或消失,因为我正在从该按钮发送时间戳值,并且当用户在一段时间后单击此按钮时,它将获得新的时间戳.
请帮忙.




how can i disable or disappear from the page this Accept button after first click because i am sending a timestamp value from this button and when a user click this button after some time then it will get new timestamp.
please help.


正如Sergey所提到的,您不能直接从php中做到这一点.但是您可以输出将执行此操作的适当的javascript.

我不使用字符串连接在php中构造页面,而是自己使用DOM方法.但是无论如何,您都可以使用以下方法完成任务:

As Sergey mentions, you can''t do it ''directly'' from php. But you can output the appropriate javascript that will do so.

I don''t construct pages in php using string concatenation, preferring the DOM methods myself. But in any case, you can achieve the task with the following:

<td>
  <button onclick="get_accept('<?php echo


data ['id'];?>'); this.disabled ='disabled';" < /button > < /td >
data['id'];?>'); this.disabled='disabled';">Accept</button> </td>



您可以在最简单的页面上看到它:



You can see it in action with the simplest of pages:

<html>
  <head>
  </head>
  <body>
    <button onclick="this.disabled='disabled';">Disable Me</button>
  </body>
</html>




这是进一步说明它的页面:




Here''s a page that demonstrates it further:

<?php
	


这篇关于在PHP中单击后如何禁用按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆