jjqbunty Posted June 13, 2019 Share Posted June 13, 2019 <script type="text/javascript"> function qtycheck() { var A = "qty_'+row_id+'".value; var B = "qtyact_'+row_id+'".value; if (A = or > B) { "qty_'+row_id+'".value=0 alert("not allowed"); } else { alert("OK"); } } </script> Link to comment Share on other sites More sharing options...
Funce Posted June 13, 2019 Share Posted June 13, 2019 What issues are you having with this code? Link to comment Share on other sites More sharing options...
jjqbunty Posted June 14, 2019 Author Share Posted June 14, 2019 I want when this function called by a button onchange, number in "qty" must not be greater then the number in "qtyact" if its greater then this will show the error... Here we have multiple rows.. Sorry I am just a beginner and found this Inventory Source Code from the web.. and found a missing very important validation. Thanks in Advance.. Link to comment Share on other sites More sharing options...
jjqbunty Posted June 14, 2019 Author Share Posted June 14, 2019 Code with Single/First Line is working fine (below) with below code. But after modification for multiple rows... my knowledge and even google is not able to help me :):) <script type="text/javascript"> function qtycheck() { var l = qty_1.value; var h = qtyact_1.value; //alert("hi " + h + " lo " + l); if (l > h) { qty_1.value=0 alert("not allowed"); } else { alert("OK"); } } </script> Link to comment Share on other sites More sharing options...
justsomeguy Posted June 14, 2019 Share Posted June 14, 2019 If you want to check if something is greater than or equal, instead of this: if (A = or > B) you do this: if (A >= B) Here's a list of operators: https://www.w3schools.com/jsref/jsref_operators.asp Link to comment Share on other sites More sharing options...
jjqbunty Posted June 15, 2019 Author Share Posted June 15, 2019 Thanks for the reply "justsomeguy" let me test.. Please comments on the second option as well... var A = "qty_'+row_id+'".value; var B = "qtyact_'+row_id+'".value; above code is fine? while I have multiple line to call.. Sorry for my bad programming knowledge Link to comment Share on other sites More sharing options...
justsomeguy Posted June 17, 2019 Share Posted June 17, 2019 No, that code probably isn't going to work like you expect. What exactly are you trying to do there? If you're trying to get the value of an input element, you need to use something like document.getElementById to get the element. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now