Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

If statement in .aspx page

I am attempting to include an If statement in some Javascript on my .aspx page.

I declare FinishedPacking at the beginning of the page as False. Then when a user clicks the orderSubmit button, the if Statement evaluates if the value is indeed false, if so, display an alert. So far the if statement does not work. If I use just the alert with no if statement it displays the alert:

    var FinishedPacking = false;

    $("#orderSubmit").click(function (e) {
       if (FinishedPacking = false) {
       alert("The order is not finished.")
       }
       ClearScreen();
       GetOrder();
    }):

As stated if I do not include the if statement, the alert works when I click the order button. Not sure why this simple If statement is not being picked up.

like image 444
Mark Saluta Avatar asked Apr 09 '26 13:04

Mark Saluta


2 Answers

You need the double-equals

if (FinishedPacking = false)

should be

if (FinishedPacking == false)

like image 136
Paul Spangle Avatar answered Apr 12 '26 03:04

Paul Spangle


Try this

var FinishedPacking = false;

$("#orderSubmit").click(function (e) {
   if (FinishedPacking == false) {
   alert("The order is not finished.")
   }
   ClearScreen();
   GetOrder();
}):
like image 33
iJade Avatar answered Apr 12 '26 03:04

iJade



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!