string to Integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • renuami
    New Member
    • Feb 2009
    • 15

    string to Integer

    Hi

    I need the output as Integer value.

    My textBox1 value is 3 and the output i am receiving is 33 instead of 6.
    Please advise what is wrong with the below code.

    Thanks


    var temp=document.g etElementById(' textBox1');

    alert("Int value is "+parseInt(temp .value) +3);
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    alert("Int value is "+(parseInt(tem p.value) +3));
    Add parentheses around the integers, otherwise the + operators are processed strictly left to right.

    Comment

    Working...