Mertegysgombvalto/amerikai.html
knyiharrolandjanos 51e41692b3 11
2022-10-07 11:29:27 +02:00

102 lines
2.1 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Mértékegység átváltó</title>
</head>
<body>
<form name='terfogat' style=' width: 320px; margin:32px auto; '>
<input type = 'text' name= 'pint' size=5
onFocus = 'document.terfogat.reset()'
onBlur = 'terfogat_szamol("pintből")' > pint
<input type = 'button' value=' számol'
style = 'margin:24px;'>
<input type = 'text' name= 'liter' size=5
onFocus = 'document.terfogat.reset()'
onBlur = 'terfogat_szamol("literből")' > liter
</form>
<script>
function huvelyk_szamol(mibol)
{
huvelyk = parseFloat( document.tav.huvelyk.value )
cm = parseFloat( document.tav.cm.value )
if( mibol=="hüvelykből" && huvelyk >0 )
{
document.tav.cm.value = huvelyk / 2.56
}
if( mibol=="cmből" && cm>0 )
{
document.tav.huvelyk.value = cm * 2.56
}
}
</script>
<form name='tav' style=' width: 320px; margin:32px auto; '>
<input type = 'text' name= 'hüvelyk' size=5
onFocus = 'document.tav.reset()'
onBlur = 'huvelyk_szamol("hüvelykből")' >huvelyk
<input type = 'button' value=' számol '
style = 'margin:24px;'>
<input type = 'text' name= 'cm' size=5
onFocus = 'document.tav.reset()'
onBlur = 'huvelyk_szamol("cmből")' > cm
</form>
<script>
function terfogat_szamol(mibol)
{
pint = parseFloat( document.terfogat.pint.value )
liter = parseFloat( document.terfogat.liter.value )
if( mibol=="pintből" && pint >0 )
{
document.terfogat.liter.value = pint * 0.473
}
if( mibol=="literből" && liter>0 )
{
document.terfogat.pint.value = liter / 0.473
}
}
</script>
</body>
</html>