Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Klint Youngmeyer
PicoTestSite
Commits
ecee01c6
Commit
ecee01c6
authored
Dec 09, 2019
by
Klint Youngmeyer
Browse files
Add dropdown to select which LED to toggle
parent
a539f68f
Changes
1
Hide whitespace changes
Inline
Side-by-side
www/page2.html
View file @
ecee01c6
...
...
@@ -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
'
}));
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment