Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    How to fix this error

    I encounter the some problem while adding the array elements like
    h[i]=a[i]+b[i]+c[i]

    when a[i]=1 b[i]=2 c[i]=3, it makes h[i]=123

    It treats the array elements as characters.
    I use
    <input type="text"> command to insert elements into arrays...


    Plz anyboby help.....

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Inputs are strings by default. You need to use parseInt(a[i]) + parseInt(b[i]) + parseInt(c[i]).
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • #3
    New to the CF scene
    Join Date
    Jun 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Wow.....That really worked buddy. Thanks a lot for your help.

    Im a begineer in this language. I got nice infos from this web, keep up the work.
    Bye..

    If i encounter any errors, i will consult u.

    Thanks a lot.

    *Topic to be lOcKeD*


  •  

    Posting Permissions

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