我有一个带有两个文本框的表单。我想在一个框中输入一个数字,按“转换”链接,让它将第一个框中的数字计算为摄氏度并将其放在第二个文本框中。到目前为止它不起作用,我觉得我缺少一些小东西......我该怎么办?
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css">
body
{
background-color: white;
}
h2
{
position: absolute;
left:200px;
top:5px;
color: cadetblue;
}
p
{
text-align: center;
font-family: times new roman;
color: black;
}
</style>
<script>
function f2cCalc(input)
{
var fbox = document.getElementById(input);
var cbox = document.getElementById(cinput);
var f = parseInt(fbox.value);
var cel = Math.round(5/9*(f-32));
document.getElementById(cbox).value=cel;
}
</script>
</head>
<body>
<form method="get" action="">
<h2>Temp calculator</h2>
<br />
<br />
<br/>
<br/>
<br/>
F<input id="finput" type="number" STYLE="background-color: cadetblue; color: green;" value="0"/>
C<input id="cinput" type="number" STYLE="background-color: cadetblue; color: green;" value="0"/>
<a href="javascript:f2cCalc(finput)">Convert</a>
</form>
</body>
</html>
enter code here