Develop a HTML Form, which accepts any Mathematical expression. Write JavaScript code to Evaluates the expression and Displays the result.

<html>
<head>
<title>Mathematical Expression</title>
<script type = "text/javascript">
    function math_exp()
    {
        var x = document.form1.exptext.value;
        var result = eval(x);
        document.form1.resulttext.value = result;
    }
</script>
</head>
<body >
    <form name = "form1">
        <table>
            <tr>
                <td>Expression</td>
                <td><input type = "text" name = "exptext" /></td>
            </tr>
            <tr>
                <td>Result</td>
                <td><input type = "text" name = "resulttext" /></td>
            </tr>
            <tr>
                <td><input type = "button" value = "calculate" onclick = "math_exp()" /></td>
            </tr>
        </table>
    </form>
</body>
</html>

1 comment:

  1. That was very value coding information
    really helped me
    will also share them on my blog

    Thanks for sharing

    Get trained on digital marketing training with our industrial experts in
    seo training in bangalore join us

    ReplyDelete