ScotDiddle Posted December 9, 2009 Share Posted December 9, 2009 Hi Folks, I have a simple js function which is called during onBlur of an input field. if (7 > 9) { } is returning true. ...but not always... Can anyone see anything wrong with my code ? See the last "if" statement... function checkInventory(quan,curval,thisid,closeout) { // alert(closeout); closeoutBoolean = closeout; if (curval < quan || curval == quan) { thisid++ ; var quanFeild = document.getElementById(thisid); quanFeild.value = quan; } if (curval == '0' || curval == '') { var quanFeild = document.getElementById(thisid); quanFeild.value = ''; } alert('curval ' + curval); alert('quan ' + quan); if (curval > quan) { $(document).ready(function(){ var url = "<?php echo $toodles; ?>backorder.php?height=375&width=375&modal=true&curval=" + curval + "&quan=" + quan + "&quanid=" + thisid + "&closeout=" + closeoutBoolean; tb_show("",url,""); }); } } Thanks, Scot L. Diddle, Richmond VA Quote Link to comment https://forums.phpfreaks.com/topic/184532-javascript-if-x-y-do-somthing-not-working/ Share on other sites More sharing options...
ScotDiddle Posted December 9, 2009 Author Share Posted December 9, 2009 Salutations, Turns out that passing '7' is not the same as passing 7. My onBlur call to the JS Function was passing 7, and this resulted in a JS error, so I change it to '7'. To fix the error, I had to turn the text I was passing in to an INT, via: quan = quan * 1; curval = curval * 1; Silly Me. Thanks for looking. Scot L. Diddle Quote Link to comment https://forums.phpfreaks.com/topic/184532-javascript-if-x-y-do-somthing-not-working/#findComment-974227 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.