Depressed thing, look at the front desk HTML:

purchase quantity: <Input id="txtNum" type="text" value="http://www.script-home.com//article/1" runat="server"/>(
parts inventory <span id="getGoodsNum" ><%=GOODSNUM % ></span>) A

with JS values, look for the JS code:

var num=document. The getElementById (" txtNum "). The value;
var goodsnum=document. GetElementById (" getGoodsNum "). The innerHTML;

everybody will find getGoodsNum txtNum and accessor methods.
txtNum is used. The value, getGoodsNum use. InnerHTML.
because getGoodsNum is to use a span tag, txtNum is a text box.
span, a table, div has no value, so using innerHTML value.
txtNum belongs to the text box, and lable, drop-down box has value (value).
. Now you know.
now talk about the two Numbers for comparison. You must think, the two got now.
please see JS code:

if (num >goodsnum) {
alert (" shopping quantity cannot be greater than the inventory quantity! ");
return false.
}

it shouldn't be a problem, two Numbers, then I lose data, contrast ah. Num lose 100, goodsnum is 90, validation, normal. Then num lose 90, goodsnum lost 90. Verification, we have a problem, prompt the shopping quantity is not greater than the inventory quantity! . What is wrong with this. Then the two output parameters with alert, yes ah, then yes. By the way, the two Numbers is of type string? How to forget, my brain was short circuit. Under the transformation.
now offers two methods, One:

if ((num/1) >goodsnum/1) {
alert (" shopping quantity cannot be greater than the inventory quantity! ");
return false.
}

so remove 1 with respect to OK, verify the sad.
Two:

if (parseInt (num) >parseInt (goodsnum)) {
alert (" shopping quantity cannot be greater than the inventory quantity! ");
return false.
}

OK, through, solved.
the author: Mr S.R Lee
the source: http://www.cnblogs.com/LeeYongze


This concludes the body part