JavaScript Convert String To Int

How To Parse String To Number Using Javascript

Parse String To Int Using JavaScript



In This Javascript Tutorial we will see How To Convert String To Int Using parseInt() In JS Using Netbeans Editor .




Project Source Code:

<!DOCTYPE html>
<html>
    <head>
        <title>JavaScript: Convert String To Number</title>
        <meta charset="windows-1252">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        
        <script>
            
            function convertToInt()
            {
                var n1 = parseInt(document.getElementById('n1').value);
                var n2 = parseInt(document.getElementById('n2').value);
                
                document.getElementById('result').value = n1 - n2;
            }

        </script>
        
    </head>

    <body>

        <input type="text" id="n1"/>
        -
        <input type="text" id="n2"/>
        <button onclick="convertToInt();">=</button>
        <input type="text" id="result"/>

    </body>

</html>




Share this

Related Posts

Previous
Next Post »