I am trying to use a new feature for my simple tool that will essentially add a "guided" way of using it.
How it works is: if a user clicks on a button, it will suggest (enable) and disable other buttons.
Now I've realized that some users won't like this restricted access to the tool, that's why I'd like to ask if it's possible to add a toggle in the settings to turn on/off this feature. I'd like it be turned on by default.
Simply put, the toggle should mean: If it's turned on, allow "guided" feature. If turned off, disable this feature and let the user click on any button they want.
Here's my sample:
function resetall() {
document.getElementById("2nd").disabled = false;
document.getElementById("1st").disabled = false;
document.getElementById("3rd").disabled = false;
document.getElementById("4th").disabled = false;
}
function disable1st() {
document.getElementById("1st").disabled = true;
document.getElementById("2nd").disabled = false;
document.getElementById("3rd").disabled = true;
document.getElementById("4th").disabled = true;
}
function disable2nd() {
document.getElementById("2nd").disabled = true;
document.getElementById("1st").disabled = false;
document.getElementById("3rd").disabled = false;
document.getElementById("4th").disabled = true;
}
.switch {
position: relative;
display: inline-block;
width: 60px;
height: 34px;
}
.switch input {
opacity: 0;
width: 0;
height: 0;
}
.slider {
position: absolute;
cursor: pointer;
top: 0;
left: 0;
right: 0;
bottom: 0;
background-color: #ccc;
-webkit-transition: .4s;
transition: .4s;
}
.slider:before {
position: absolute;
content: "";
height: 26px;
width: 26px;
left: 4px;
bottom: 4px;
background-color: white;
-webkit-transition: .4s;
transition: .4s;
}
input:checked + .slider {
background-color: #2196F3;
}
input:focus + .slider {
box-shadow: 0 0 1px #2196F3;
}
input:checked + .slider:before {
-webkit-transform: translateX(26px);
-ms-transform: translateX(26px);
transform: translateX(26px);
}
.slider.round {
border-radius: 34px;
}
.slider.round:before {
border-radius: 50%;
}
<button id="reset" onclick="resetall()">Reset</button>
<br><br>
<button id="1st" onclick="disable1st()">1</button>
<button id="2nd" onclick="disable2nd()">2</button>
<button id="3rd" onclick="disable3rd()">3</button>
<button id="4th" onclick="disable4th()">4</button>
<br><br>
<!---This toggle button--->
<label class="switch">
<input type="checkbox" checked>
<span class="slider round"></span>
</label>
I'd like to apologize in advance if I don't have much code to show for. I'm new to coding and still learning... but I'd really want to have this feature if it's possible. Thanks in advance, I'd really appreciate any feedback/suggestion.
EDIT:
To hopefully explain my question further, here's a screenshot of the tool.
As you may see, there are several buttons that when clicked, will react by inserting a specific text into the textarea, and more importantly disable any buttons that won't fit in as the continuation of the clicked button.
Now I'm looking for a feature that will turn on/off this "guided" mode, possibly by using a checkbox, if ticked or not ticked, or a toggle, what's important is to turn of the script attached above.
This feature should turn on/off "guided mode" if the user prefers to not have it. Therefore, they should be able to click any buttons as they wish without the restrictions of a disabled button.
The script provided above is a simpler version, but it's exactly what I need and been using. I just want to be able to turn it on/off via toggle without coding.