I created a webUI to control a relay board with a raspberry pi.
When a button is pressed I access the relais.php with an AJAX request. The relais.php sends the corresponding commands to a python script from where the relays are controlled.
<!DOCTYPE html>
<html>
<body>
<label class="switch">
<input type="checkbox" id="IN1" onclick="in1()">
</label>
</body>
<script>
function in1() {
var x = document.getElementById("IN1").checked;
var xhttp = new XMLHttpRequest();
xhttp.open("GET", "relais.php?dir=IN1=" + x, true);
xhttp.send();
var out1 = x; }
</script>
</html>
The problem is the page gets reloaded the buttons are reset to the "unchecked" state. How could I store the states of the inputs on the webserver? The result would be that I could access the webUI from another device and the buttons would be "remembered" every time I reload.