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>
<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 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 id='switchMsg' align='center'>______</p>
Send questions to <a href=""></a>.
<a href="index.html">Home</a>
function toggleLED() {
function toggleLED(led_num) {
var xhr = new XMLHttpRequest();"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'];
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