You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
1.2 KiB
28 lines
1.2 KiB
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Ovládání LED pásku</title>
|
|
</head>
|
|
<body>
|
|
<h1>Ovládání LED pásku</h1>
|
|
<form id="ledForm">
|
|
<label for="barvaLed">Barva LED:</label>
|
|
<input type="color" name="barvaLed"
|
|
id="barvaLed" value="#FF0000">
|
|
<input type="submit" value="Nastavit">
|
|
</form>
|
|
<script>
|
|
//nalezneme elements s id ledForm a nastavíme odposlech na "submit" který po aktivaci aktivuje funkci
|
|
document.getElementById("ledForm").addEventListener("submit", function(event){
|
|
event.preventDefault(); //nepřesměruje stránku -> kod bude pokračovat
|
|
var barva = document.getElementById("barvaLed").value; //získání hodnoty z formuláře
|
|
var xhr = new XMLHttpRequest(); //vytvoření nového požadavku
|
|
xhr.open("POST","/nastavit",true); //nstavení odkazu kam budeme posílat požadavky
|
|
xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded"); //nastavení hlavičky pro snažší odeslání
|
|
xhr.send("barva="+barva);
|
|
})
|
|
</script>
|
|
</body>
|
|
</html>
|