How Can I Change An Html Input Value's Data Type To Integer?
I'm using jQuery to retrieve a value submitted by an input button. The value is supposed to be an integer. I want to increment it by one and display it. // Getting immediate Voting
Solution 1:
To convert strValue into an integer, either use:
parseInt(strValue, 10);
or the unary + operator.
+strValueNote the radix parameter to parseInt because a leading 0 would cause parseInt to assume that the input was in octal, and an input of 010 would give the value of 8 instead of 10
Solution 2:
parseInt( $("#"+countUp).val() , 10 )
Solution 3:
Use parseInt as in: var count = parseInt($("#"+countUp).val(), 10) + 1; or the + operator as in var count = +$("#"+countUp).val() + 1;
Solution 4:
Solution 5:
var count = parseInt(countUp, 10) + 1;
Post a Comment for "How Can I Change An Html Input Value's Data Type To Integer?"