www.webdeveloper.com
Results 1 to 2 of 2

Thread: Wrong Sum Result

  1. #1
    Join Date
    Dec 2011
    Posts
    39

    Wrong Sum Result

    Sir I am using your following codes

    Code:
    function total(objForm) {
       var num1 = objForm.text1.value.replace(',', '');
        var num2 = objForm.text2.value.replace(',', '');
    	   objForm.text3.value = Number(num1) + Number(num2);
      }
    it show accurate result when there is only once , (comma) in digits but it show Nan (Nothing) there are two commas in textbox.

    Please see image

    http://i44.tinypic.com/dvn4ic.jpg

    Please help

  2. #2
    Join Date
    Dec 2005
    Location
    FL
    Posts
    7,412
    Try ...
    Code:
    function total(objForm) {
       var num1 = objForm.text1.value.replace(/\,/g, '');
        var num2 = objForm.text2.value.replace(/\,/g, '');
    	   objForm.text3.value = Number(num1) + Number(num2);
      }

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles