Hoe OM - Speed Converter
Leer hoe om 'n spoedomskakelaar met HTML en JavaScript te skep.
Spoed Converter
Tik 'n waarde in enige van die velde om tussen spoedmetings om te skakel:
Skep 'n spoedomskakelaar
Skep 'n invoerelement wat 'n waarde van een spoedmeting na 'n ander kan omskakel.
Stap 1) Voeg HTML by:
Voorbeeld - MPH tot KPH
<p>
<label>MPH</label>
<input id="inputMPH" type="number" placeholder="MPH"
oninput="speedConverter(this.value)"
onchange="speedConverter(this.value)">
</p>
<p>KPH: <span id="outputKPH"></span></p>
Stap 2) Voeg JavaScript by:
Voorbeeld - MPH tot KPH
/* When the input field receives input, convert the value from mph to kph */
function speedConverter(valNum) {
valNum = parseFloat(valNum);
document.getElementById("outputKPH").innerHTML = valNum * 1.609344;
}
Skakel van MPH na ander metings
Die tabel hieronder wys hoe om van MPH na ander spoedmetings om te skakel:
Description | Formula | Example |
---|---|---|
Convert from MPH to KPH | KPH=MPH*1.609344 | |
Convert from MPH to Knots | knots=MPH/1.150779 | |
Convert from MPH to Mach | Mach=MPH/761.207 |
Skakel van KPH om na ander metings
Die tabel hieronder wys hoe om van KPH na ander spoedmetings om te skakel:
Description | Formula | Example |
---|---|---|
Convert from KPH to MPH | MPH=KPH/1.609344 | |
Convert from KPH to Knots | knots=KPH/1.852 | |
Convert from KPH to Mach | Mach=KPH/1225.044 |
Skakel van knope om na ander mates
Die tabel hieronder wys hoe om van Knots na ander spoedmetings om te skakel:
Description | Formula | Example |
---|---|---|
Convert from Knots to MPH | MPH=knots*1.150779 | |
Convert from Knots to KPH | KPH=knots*1.852 | |
Convert from Knots to Mach | Mach=knots/661.4708 |
Skakel van Mach om na ander metings
Die tabel hieronder wys hoe om van Mach na ander spoedmetings om te skakel:
Description | Formula | Example |
---|---|---|
Convert from Mach to MPH | MPH=Mach*761.207 | |
Convert from Mach to KPH | KPH=Mach*1225.044 | |
Convert from Mach to Knots | knots=Mach*661.4708 |