var weight = ""; weight = $("#selectWeight").val(); if(weight == '') { alert('you must select a value first!'); }
If weight has no value, I do not get a alert box. If I add an alert after getting the weight value, then I get the alert box. Is there something about using/initializing variables that I'm missing?