samedi 5 janvier 2019

Comparing input value with else if statement don't work, what can i do?

i just did a form, take is value into variable and try to compare them between each other, but nothing is happening.

I've tried to convert the variable in integer with number() and parseInt, didn't work.

I tried to declare the variable outside of the function, didn't work

$('#calculate').click(function(){
var bill = $('#bill').val();
var serveuse = $("#myselect option:selected").val();
var sangs = $('#gars').val();
if(bill===0){
alert('something');
}
else if (bill<10){
alert('somethinge else');
}
else(gars>10 &&bill>20){
alert('something else else');
}
})

There is three input in my from, 'sangs' and 'bill' are classical input type number, 'serveuse' is an select option input. I just want to compare those three variable with a lot of else if statement to output a result.

Aucun commentaire:

Enregistrer un commentaire