Using javascript only I am trying to say if cycn = 1
, disable input element with id="prevdl"
if cycn > 1
, then do not disable element with id="prevdl"
, and in both cases
preview the value of cycn in the <p>
with id="transit"
but condition after if (cycn = 1)
is executed no matter what. And the one after else is not seen at all
HTML
<label for="cyclecount">Cycle Count:</label>
<input type="number" id="cyccnt" name="cyclecount" placeholder="Today's cycle number" min="1" max="6" autocomplete="off" value=""><br><br>
<p id="transit"></p>
<label for="previousdoseLevel">Previous Dose Level:</label>
<input type="number" id="prevdl" name="previousdoseLevel" placeholder="Insert Previous Dose Level" autocomplete="off" value=""><br><br>
Javascript
var cyc = document.getElementById("cyccnt");
var cycn = Number(cyc.value);
document.getElementById("cyccnt").oninput = function (e) {
if (cycn = 1) {
document.getElementById("prevdl").disabled = true;
document.getElementById("transit").innerHTML = cycn;
} else if (cycn >1) {
document.getElementById("prevdl").disabled = false;
document.getElementById("transit").innerHTML = cycn;
}
e.preventDefault(e);
}
please help and thanks in advance.