I’m creating a application using JS and HTML and was wondering how to implement a button that will update a value with the parameters of three items to choose from.
Here was I got so far:
**This is how the “value” is displayed in html – **
<div id="md" class="mdtxt">{mode}</div>
**Using the following script to automatically update the value from default through js – **
<script> document.getElementById("md").innerHTML = currentMode; </script>
**Here is the js side of things – **
script.js will let currentMode = null;
(is nulled to demostrate default)
config.js defines modes as config.zones = [ { modeid: 1, modetag: "Mode #1", }, { modeid: 2, modetag: "Mode #2", }, { modeid: 3, modetag: "Mode #3", }, ]
Hopefully I gave a good understanding, now I want my html button to be able to cycle through the modes and then wrap back around to the first one in a continuous cycle.
I have a html button element with a id so the element would be id="btns1"
I’ve tried to use some code from a previous project, as well as watch so youtube tutorials but nothing seems to be helping me understand this.