我创建了我的<form>
usingHtmL
现在我需要知道如何创建一个函数,我可以返回一个值来填充我的Input type="text"
.
例如: 更新
<html>
<head>
<title>Aula 21.03.2013 </title>
<script>
function CalculaNota()
{
var p1 = document.getElementById("txtp1").value;
var p2 = document.getElementById("txtp2").value;
return p1;
}
</script>
</head>
<body>
<div id="fieldset" style="border: 2px solid pink; width: 250px; margin-left: auto; margin-right: auto; padding: 10px;" >
<form name="formulario" action="" method="post">
P1<br>
<input type="text" id="txtp1" /><br>
P2<br>
<input type="text" id="txtp2" /><br>
<input type="submit" value="CALCULAR" OnClick="CalculaNota()"/>
<br><br>
NOTA FINAL<br>
<input type="text" id="txtnota_final"/>
</form>
</div>
</body>
</html>
现在,当我单击按钮时,什么也没有发生!