I am new here and new to Javascript, I have looked through many of the questions and answers here relating to using IF/ELSE but I still can’t seem to get what I have working.
What I have is a page with a user input, so based upon the number entered I want to do one calculation if TRUE and another if FALSE. I would be grateful of any help or guidance. Script below:
<script language="javascript" type="text/javascript">
function calculate()
if ($("#lvl").val() < 50)
{
let lvl_fld={}
lvl_fld.level = Math.floor($("#lvl").val() * 1.5 + 4.5)
$("#flds").val(lvl_fld.level);
let total = Math.floor(lvl_fld.level);
$("#total_value").text(total);
}
else
{
let lvl_fld={}
lvl_fld.level = Math.floor($("#lvl").val() * 2 + 8)
$("#flds").val(lvl_fld.level);
let total = Math.floor(lvl_fld.level);
$("#total_value").text(total);
}
$(function()
{
$(".qty").on("change keyup",calculate)
})
</script>