Adding numerical values in javascript

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • stylishjm
    New Member
    • Jan 2010
    • 27

    #16
    OK what would I have to chage it to? Is there an alternative to parsefloat?

    Comment

    • Dormilich
      Recognized Expert Expert
      • Aug 2008
      • 8694

      #17
      the alternative is not using p[1], but the correct value.

      the incorrect thing is: p[1] = "ha8+7ej%C2%A0U K"

      Comment

      • stylishjm
        New Member
        • Jan 2010
        • 27

        #18
        so I would put this instead for example?
        document.getEle mentById("5").i nnerHTML = parseInt(price2 .replace('+', ' ').replace('%C2 %A3', '£').replace(' UK', ' '))+15;
        Edit: Still comes up with NaN

        Comment

        • Dormilich
          Recognized Expert Expert
          • Aug 2008
          • 8694

          #19
          of course, parseFloat("ha8 ") naturally returns NaN.

          Comment

          • stylishjm
            New Member
            • Jan 2010
            • 27

            #20
            in the example I showed in the post before this one, the value is 'price2' which is the id of the variable passed over that I need to be "parsed" yet it still doesnt work. It doesnt contain any addresses or what not, just numbers and "£" sign.

            Comment

            • Dormilich
              Recognized Expert Expert
              • Aug 2008
              • 8694

              #21
              tip: check your html

              works neither in Chrome nor Safari
              Error: NO_MODIFICATION _ALLOWED_ERR: DOM Exception 7 - Booking2.html:1 89

              findings from Dragonfly:
              p[1] = "%A311.60" which is parsed into NaN, or in other words, your replace search string doesn’t match.

              Comment

              Working...