简体   繁体   English

单击第二个按钮后运行HTML脚本的HTML按钮

[英]HTML Button to run a PHP script following a second click

I am using HTML on a Raspberry Pi to control relays, currently I have a button for the On and another for the Off of the GPIO, I was wondering if there was a way I could press a single button once to call the On.php and press the same button a second time to call the Off.php without leaving the page. 我在Raspberry Pi上使用HTML来控制继电器,目前我有一个GPIO的“ On”按钮和另一个“ Off”按钮,我想知道是否有一种方法可以一次按一个按钮来调用On.php。并再次按下相同的按钮以调用Off.php,而无需离开页面。

Right now one button moves to the PHP script page which turns the GPIO On and then returns to the home page, the Off button does the same. 现在,一个按钮移到PHP脚本页面,该页面打开GPIO,然后返回主页,“关闭”按钮执行相同的操作。 This is a bad method but it worked. 这是一个不好的方法,但是它起作用了。

Seting a global variable to calculate the times of your clicking (flag==0). 设置全局变量以计算您的点击次数(flag == 0)。 Then writing something to define which functions you want to use. 然后编写一些内容来定义要使用的功能。

我为输入使用了一个复选框,单击该复选框时会调用一个函数,然后检查是否被勾选,然后代码使用变量来确定GPIO引脚应处于什么状态。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM