How Can I Convert From KPH To Knots Using Javascript

admin_img Posted By Bajarangi soft , Posted On 27-11-2020

In java script we can create an input element that can convert a value from one speed measurement(KPH) to another(Knots ).So for that we use formula knots=KPH/1.852.

How Can I Convert From KPH To Knots Using Javascript

Complete Code For Converting From KPH To Knots Using Javascript.

<!DOCTYPE html>
<html>
<head>
    <title>How Can I Convert From KPH To Knots Using Javascript</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.0/css/bootstrap.min.css" rel="stylesheet">
</head>
<style>
    body {
        background: black;
    }
    .form-control{
        width:80%;!important;
    }
</style>
<body>
<body>
<div class="container">
    <br/><br/>
    <div class="text-center">
        <h1 id="color" style="color: white;">Convert From KPH To Knots Using Javascript</h1>
    </div>

    <div class="well">
        <p>
            <label>KPH</label>
            <input id="inputKPH" class="form-control" type="number" placeholder="KPH" oninput="speedConverter(this.value)" onchange="speedConverter(this.value)">
        </p>
        <p>Knots: <span id="outputKnots"></span></p>

        <script>
            function speedConverter(valNum) {
                document.getElementById("outputKnots").innerHTML=valNum/1.852;
            }
        </script>
    </div>
</div>
</body>
</html>

Related Post