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 Coder
    Join Date
    Aug 2007
    Location
    Ballarat
    Posts
    22
    Thanks
    0
    Thanked 1 Time in 1 Post

    converting or adding two strings as numbers?

    is surely a simple question.... and comes down to this... can i add two strings which are supposed to be numbers together?

    x = 5+6

    = 11

    x = "5" + "6"

    = 56

    the reason I ask is because I have two values inside input boxes on a form (html), and when I try to add the two values together, it appends then as if they are strings!

    i can post the code if needed, although if you can fix the "5" + "6" above to return 11, that would fix it too

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    New Coder
    Join Date
    Aug 2007
    Location
    Ballarat
    Posts
    22
    Thanks
    0
    Thanked 1 Time in 1 Post
    Thanks. I have used the Numbers() method in the end, very handy.
    Can I then refer to a dynamic location? for example:

    currentLetter = a // The current increment
    form.testbox[currentLetter].value = 'Im in the right place!'
    // form being the form called, and end result should be form.testboxa.value = '...'


  •  

    Posting Permissions

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