SUM TEXTFIELD VALUES

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Filiz Duman

    SUM TEXTFIELD VALUES

    Hi,
    was just wondering how I can sum values from different textboxes,..
    I used "+" but this adds the values together rather then creating a sum of
    them.

    e.g.

    var x = document.clear. field1.value; (e.g. 10)
    var y = document.clear. field2.value; (e.g. 11)

    var sum = x + y (that comes up with 1011) rather then 21.
    How can I add them together so the result is 21 ?
    Any ideas.
    Thanks


  • Randy Webb

    #2
    Re: SUM TEXTFIELD VALUES

    Filiz Duman wrote:[color=blue]
    > Hi,
    > was just wondering how I can sum values from different textboxes,..
    > I used "+" but this adds the values together rather then creating a sum of
    > them.
    >
    > e.g.
    >
    > var x = document.clear. field1.value; (e.g. 10)
    > var y = document.clear. field2.value; (e.g. 11)
    >
    > var sum = x + y (that comes up with 1011) rather then 21.
    > How can I add them together so the result is 21 ?
    > Any ideas.
    > Thanks[/color]



    var sum = +x + +y;


    --
    Randy

    Comment

    Working...