parse a number to float problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • baris22
    New Member
    • Jan 2010
    • 5

    parse a number to float problem

    hello,

    i know php but i have got no knowledge on ajax. this is the function my programmer made long time ago. it is showing the total value on the text areas. The problem am facing now is:

    forexample if the value on the field is: 1.50 it turns into 1.

    What can i do to solve the problem. i think it is something to do with parseInt

    Code:
    function amtTot(){
    
    	//fee_tot1
    	//alert(document.getElementById("fee_tot1").value);
    	var tot_amt=parseInt(document.getElementById("fee_tot1").value)+parseInt(document.getElementById("fee_tot2").value)+parseInt(document.getElementById("fee_tot3").value)+parseInt(document.getElementById("fee_tot4").value)+parseInt(document.getElementById("fee_tot7").value)+parseInt(document.getElementById("fee_tot8").value);
    	//alert(tot_amt);
    	document.getElementById("tot_amt").value=tot_amt;
    	addValueText();
    	//tot_amt
    }
    thanks all.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    i think it is something to do with parseInt
    that’s right. parseInt() creates integer values. what you want are floats, thus parseFloat().

    Comment

    • baris22
      New Member
      • Jan 2010
      • 5

      #3
      thanks alot. it works perfect now

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        thread title changed - since that has nothing to do with AJAX ... and to help other users to find the issue better it is applicable to have a better desciption that might be found by a seach ... please remember to use a good thread title

        kind regards,
        MOD

        Comment

        Working...