Logical operator errors

1. Senior Member
Join Date
Dec 1969
Posts
1,274

## Logical operator errors

For an editable backorder page, I&#039;ve got a JavaScript clientside function on the page that checks when a user changes a quantity of a backordered item to make sure they don&#039;t increase the quantity, compared against a value in a hidden textbox that&#039;s filled when the page loads. Here&#039;s the code:<BR><BR>function invalidQtyCheck(id) {<BR> var strOldQty;<BR> var strNewQty;<BR> strOldQty = id + &#039;C4&#039;;<BR> strNewQty = id + &#039;C5&#039;;<BR> if (window.document.frmEBO[strNewQty].value == &#039;&#039;) {<BR> window.document.frmEBO[strNewQty].value = window.document.frmEBO[strOldQty].value;<BR> }<BR> if (window.document.frmEBO[strNewQty].value &#062; window.document.frmEBO[strOldQty].value) {<BR> alert(window.document.frmEBO[strOldQty].value + "&#060;" + window.document.frmEBO[strNewQty].value);<BR> alert(&#039;You cannot increase the Order Quantity for back-ordered items.&#039;);<BR> window.document.frmEBO[strNewQty].focus();<BR> window.document.frmEBO[strNewQty].select();<BR> }<BR>}<BR><BR>Basically, I pass an ID of a row in, and it checks the row values. For some strange reason, the code tells me that 99&#062;100, 9&#062;48, and 100&#062;436 when I try those values. Why would this happen?<BR><BR>I don&#039;t see any logical errors anywhere, and I&#039;ve placed isNaN() functions around the values, and both returned false.

2. Senior Member
Join Date
Dec 1969
Posts
7,686

## RE: Logical operator errors

Most of these kinda problems are because the numbers are seen as text, although that wouldn&#039;t explain why 100&#062;436, but it does explain why 99&#062;100! It&#039;s worth a try to turn the values from the inputboxes to an integer <BR><BR>if (parseInt(window.document.frmEBO[strNewQty].value) &#062; parseInt(etc. etc.)<BR><BR>

3. Senior Member
Join Date
Dec 1969
Posts
1,274

## RE: Logical operator errors

Thanks Dutch, that did the trick! See, the isNaN thing threw me off, because since it returned false, I assumed the values were being interpreted as integers... apparently not. Woohoo!

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•