Commit ecee01c6 authored by Klint Youngmeyer's avatar Klint Youngmeyer
Browse files

Add dropdown to select which LED to toggle

parent a539f68f
......@@ -30,19 +30,37 @@
<H2>This is the second page</H2>
<p>This page is just to demonstrate linking to other local pages, and to test JavaScript stuff.
<p align='center'>
<button type='button' class='btn' align='center' style='height:30px; width:70px' onclick='toggleLED()'>Toggle</button>
<select id="ledNumber">
<option value=1>1</option>
<option value=2>2</option>
<option value=3>3</option>
<option value=4>4</option>
</select>
<button id="ledToggleBtn" type='button' class='btn' align='center' style='height:30px; width:70px' onclick="toggleLED(parseInt(document.getElementById('ledNumber').value, 10))">Toggle</button>
</p>
<p id='statusMsg' align='center'>______</p>
<p align='center'>
<button id="getSwitchBtn" type='button' class='btn' align='center' style='height:30px; width:110px' onclick="getSwitch()">Get Switch</button>
</p>
<p id='switchMsg' align='center'>______</p>
<BR><BR><BR>
Send questions to <a href="mailto:supporrt@emacinc.com">support@emacinc.com</a>.
<HR>
<a href="index.html">Home</a>
<script>
function toggleLED() {
function toggleLED(led_num) {
var xhr = new XMLHttpRequest();
xhr.open("POST", "/led_control", true);
xhr.setRequestHeader('Content-Type', 'application/json');
xhr.onreadystatechange = function() {
if (this.readyState == XMLHttpRequest.DONE && this.status == 200) {
var data = xhr.responseText;
var jsonResponse = JSON.parse(data);
document.getElementById("statusMsg").innerHTML = jsonResponse['status'];
}
}
xhr.send(JSON.stringify({
number: 1,
number: led_num,
action: 'toggle'
}));
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment