Only if you tell me how you got that nice round, fat slider look 
So, I have a checkbox on the main page of a project that also uses ESPAsyncWebServer - in my case it’s a checkbox that governs whether the page auto-refreshes or not.
i.e.
<td><input type="checkbox" onclick="toggleAutoRefresh(this);" id="reloadCB" checked></td>
<td>Auto Refresh</td>
The corresponding javascript looks like this…
function toggleAutoRefresh(cb) {
if (cb.checked) {
refreshData = setInterval(updateData, 5000);
} else {
clearTimeout(refreshData);
}
}
Now, in you case, instead of setting the timer, or clearing it, you probably want to poke some endpoint on the ESP so it does then passes the instruction to the Arduino.
To do that, this function may help - it toggles a relay by first querying the current state (as displayed on the page), and then tell the ESP what the new state is to be, via a button.
<td><input type="button" id="relay" value="Load" onclick="toggleRelay()"></td>
function toggleRelay() {
var url = "";
var state = document.getElementById("relay").value;
if (state == "ON") {
state = "0";
} else {
state = "1";
}
url = url.concat("/relay", "?set=", state);
// console.log(url);
xmlhttp = new XMLHttpRequest();
xmlhttp.open("GET", url, true);
xmlhttp.send();
setTimeout(updateData, 250);
}
and finally the c++ code that responds to the relay set (or get):
server.on("/relay", HTTP_GET, [](AsyncWebServerRequest *request) {
String message;
if (request->hasParam("set"))
{
message = request->getParam("set")->value();
if (request->getParam("set")->value() == "1")
{
digitalWrite(RELAY, HIGH);
message = "Turned relay ON!";
}
else if (request->getParam("set")->value() == "0")
{
digitalWrite(RELAY, LOW);
message = "Turned relay OFF!";
}
}
else if (request->hasParam("get"))
{
message = "State of relay = " + String(digitalRead(RELAY) ? "OFF" : "ON");
}
else
{
message = "No message sent";
}
request->send(200, "text/plain", message);
});
edit: lol… I see in between me starting to respond this this about half an hour ago, and pausing for dinner, you’ve essentially solved your problem using similar code. Still want to know what you’re using to style the checkbox though! 