I'm trying to set an input field to the value of a jQuery variable but it's refusing to cooperate. Can someone please tell me what I'm doing wrong? Essentially, I'm trying to get equipment failure counts to display in an input textbox so I can write the value back to a table. Each failure counts as 1 and is added to a total (truckFailsTot variable) when users click a Y/N radio button next to each type of failure. The example below just includes one failure for brevity.
HTML
div class="form-row">
<div class="form-group col-lg-12"><label class="col-form-label" for="TruckFailCount">TruckFailCount</label>
<input class="form-control" ${disabled( 'TruckFailCount')} id="TruckFailCount" maxlength="13" name="TruckFailCount" title="truckFailCount" type="text" value="${row.truckFailCount?html}" />
</div>
</div>
jQuery - I've commented out my failed attemps below. It seems like such a simple thing, yet nothing is working.
jQuery('body').on("change",'#TruckAirCompressor',function(){
if (this.value == "Fail") {
fail_TruckAirCompressor = 1;
}
else if (this.value == "Pass") {
fail_TruckAirCompressor = 0;
}
else {
}
truckFailsTot = fail_TruckAirCompressor + fail_TruckAirLines + fail_TruckBattery
+ fail_TruckBeltsHoses + fail_TruckBody + fail_TruckBrakesAccessories + fail_TruckBrakesParking
+ fail_TruckBrakesService + fail_TruckClutch + fail_TruckCouplingDevicesHitch
+ fail_TruckDefrosterHeater + fail_TruckDriveLine + fail_TruckExhaustMuffler
+ fail_TruckFluidLevels + fail_TruckFuelTanks + fail_TruckHorn + fail_TruckLights
+ fail_TruckMirrors + fail_TruckSafetyEquipment + fail_TruckSteeringMechanism
+ fail_TruckTiresRimsWheels + fail_TruckWindows + fail_TruckWindshieldWipers;
// var t = truckFailsTot;
// $('#TruckFailCount').value(t);
// document.getElementById("#TruckFailCount").innerHTML=t;
// var val1 = truckFailsTot;
// $('#TruckFailCount').val(val1);
// var fooBar = 1;
// $('#TruckFailCount').val(fooBar);
});
Thanks in advance!
1=1is a syntax error, you can't assign to a literal.