In Javascript, functions that are used to convert from text to number are :
parseInt() , parseFloat(), number()
parseInt() fuction converts text to round number format in javascript.
Example:
var num1 = document.getElementById("textbox1").value;
var num2 = document.getElementById("textbox2").value;
var num2 = document.getElementById("textbox2").value;
var ans = parseInt( num1 + num2 );
parseFloat() function coverts text to floating number in javascript.
Example:
var num1 = document.getElementById("textbox1").value;
var num2 = document.getElementById("textbox2").value;
var num2 = document.getElementById("textbox2").value;
var ans = parseFloat( num1) +parseFloat(num2 );
::View CHEAT SHEET of JAVASCRIPT ::
No comments:
Post a Comment