Hide elements on webform until they are needed #48

Open
W1CDN wants to merge 2 commits from prettify into main
Showing only changes of commit 269cbfdd22 - Show all commits

View File

@ -186,9 +186,7 @@ const char index_html[] PROGMEM = R"rawliteral(
<script type="text/javascript"> <script type="text/javascript">
// Show more stuff depending on selected values // Show more stuff depending on selected values
// https://stackoverflow.com/a/24849350 // https://stackoverflow.com/a/24849350
document show_message = function () {
.getElementById('message')
.addEventListener('change', function () {
'use strict'; 'use strict';
var vis_message = document.querySelector('.vis_message'), var vis_message = document.querySelector('.vis_message'),
target = document.getElementById("message"+this.value); target = document.getElementById("message"+this.value);
@ -198,10 +196,8 @@ const char index_html[] PROGMEM = R"rawliteral(
if (target !== null ) { if (target !== null ) {
target.className = 'vis_message'; target.className = 'vis_message';
} }
}); }
document show_program = function () {
.getElementById('send-program')
.addEventListener('change', function () {
'use strict'; 'use strict';
var vis_program = document.querySelector('.vis_program'), var vis_program = document.querySelector('.vis_program'),
target = document.getElementById("program"+this.value); target = document.getElementById("program"+this.value);
@ -211,7 +207,13 @@ const char index_html[] PROGMEM = R"rawliteral(
if (target !== null ) { if (target !== null ) {
target.className = 'vis_program'; target.className = 'vis_program';
} }
}); }
document
.getElementById('message')
.addEventListener('change', show_message);
document
.getElementById('send-program')
.addEventListener('change', show_program);
</script> </script>
</body></html>)rawliteral"; </body></html>)rawliteral";