I have :
BtnSensor | AddSensor: ______(input) | Enter | Reset all | Set all | clear Sensors
BntGateway | AddGateway:____ (input) | Enter | Clear Gateways
I am trying to make a switch button between the button Sensor and the button Gateway.
When I click the button Sensor the button Gateway stays in function for the click but the title text, the input text area, the button Enter, and the button ClearGateway should grey out disabled.
If I clicked Button Gateway the button Sensor stays in function for the click but the title text, the input text area, the button Enter, Reset all for Shipping, Set all sensors to 10HB and clear Sensor should grey out disabled.
See the code (html/aspx):
<div class="col-12 col-md-10 col-xl-12">
<button type="button" id="btnSensor" data-id="sensorsList" data-toggleclass="btnToggle" data-togglepane="tab-pane" class="btn btn-primary btn-sm btnToggle -active" onclick="ToggleButtons('btnSensor');"> > Sensor </button>
<strong style="font-size : 15px;" id="AddSensortitle"> Add Sensor:</strong> <input type="text" id="AddSensorID" class="float-right" value="" />
<button type="button" class="btn btn-secondary btn-m fa-regular fa fa-search" role="button" aria-hidden="true" id="addSensorBtn" data-url="/Testing/AddSensor/"> Enter </button>
<button type="button" class="btn btn-primary b-btn actionBtn btn-lg fa fa-refresh" aria-hidden="true" id="resetAllForShipping" data-url="/Testing/ResetAllForShipping/"> Reset all for Shipping </button>
<button type="button" class="btn btn-primary b-btn actionBtn btn-lg fa fa-cogs" aria-hidden="true" id="setAllSensorsTo10HB" data-url="/Testing/AllSensorsTo10HeartBeat"> Set all sensors to 10 HB </button>
<button type="button" class="btn btn-primary b-btn actionBtn btn-lg fa fa-trash-o" aria-hidden="true" id="clearSensors" data-url="/Testing/ClearSensors/"> Clear Sensors </button>
<br />
<div class="clearfix"></div>
<br />
<button type="button" id="btnGateway" data-id="gatewaysList" data-toggleclass="btnToggle" data-togglepane="tab-pane" class="btn btn-primary btn-sm btnToggle inactive" onclick="ToggleButtons('bntGateway');" style="display;"> Gateway</button>
<strong style="font-size : 15px;" id="addGatewaytitle"> Add Gateway:</strong> <input type="text" id="AddGatewayID" class="float-right" value="" />
<button type="button" class="btn btn-secondary btn-m fa-regular fa fa-search" role="button" aria-hidden="true" id="addgatewayBtn" data-url="/Testing/AddGateway/"> Enter </button>
<button type="button" class="btn btn-primary b-btn actionBtn btn-lg fa fa-trash-o" aria-hidden="true" id="clearGateways" data-url="/Testing/ClearGateways/"> Clear Gateways </button>
</div>
jQuery:
<script>
function ToggleButtons(buttonId) {
var hideBtn, showBtn;
if (buttonId == 'btnSensor') {
showBtn = 'btnSensor';
hideBtn = 'btnGateway';
} else {
showBtn = 'btnGateway';
hideBtn = 'btnSensor';
document.getElementById("btnSensor").disabled = false;
document.getElementById("addSensorBtn").disabled = true;
document.getElementById("resetAllForShipping").disabled = true;
document.getElementById("setAllSensorsTo10HB").disabled = true;
document.getElementById("clearSensors").disabled = true;
document.getElementById("addSensortitle").disabled = true;
} if (buttonId == 'btnGateway') {
showBtn = 'btnGateway';
hideBtn = 'btnSensor';
} else {
showBtn = 'btnSensor';
document.getElementById("btnSensor").disabled = false;
document.getElementById("addSensorBtn").disabled = false;
document.getElementById("resetAllForShipping").disabled = false;
document.getElementById("setAllSensorsTo10HB").disabled = false;
document.getElementById("clearSensors").disabled = false;
document.getElementById("addSensortitle").disabled = false;
} if (buttonId == 'btnGateway') {
document.getElementById("btnSensor").disabled = false;
document.getElementById("addSensorBtn").disabled = false;
document.getElementById("resetAllForShipping").disabled = false;
document.getElementById("setAllSensorsTo10HB").disabled = false;
document.getElementById("clearSensors").disabled = false;
document.getElementById("addSensortitle").disabled = false;
}
else {
hideBtn = 'btnGateway';
document.getElementById("btnGateway").disabled = false;
document.getElementById("addGatewayBtn").disabled = true;
document.getElementById("clearGateway").disabled = true;
document.getElementById("addGatewaytitle").disabled = true;
}
document.getElementById(hideBtn).style.display = 'disabled';
document.getElementById(showBtn).style.display = 'enabled';
}
</script>
Thanks for your help.