locked
How to solve this logarithm code? RRS feed

  • Question

  • User-2071692902 posted

    Hi all,

    I am working on a simple logarithm calculation app.

    But I couldn't have figure out what this code didn't work. THe one highlighted bellow with factor b.

    Any help please?

    <p style="text-align: left;"><span style="text-decoration: underline; color: #ff0000;"><strong>Logarthm |Calculator</strong></span></p><button onclick="myFunction1()">Calculate Log</button>
    <button onclick="myFunction2()">Calculate Antilog</button>
    <p id="demo1"></p>
    <p id="demo2"></p>
    Number:<input type="text" id="Number" name="TextBox1">
                <br>
     Base:<input type="text" id="Base" name="TextBox2">
                <br>
    
    <script>
    function myFunction1() {
     var x = parseInt(document.getElementById("Number").value);
     var b = parseInt(document.getElementById("Base").value);
      document.getElementById("demo1").innerHTML = Math.logb(x);
    }
    </script>
    <script>
    function myFunction2() {
    var x = parseInt(document.getElementById("Number").value);
     var b = parseInt(document.getElementById("Base").value);
      document.getElementById("demo2").innerHTML = Math.pow(b,x);
    }
    </script>
    
    </body>
    </html>
    

    Tuesday, February 11, 2020 2:50 AM

Answers