应朋友需要制作的一个小页面
<script type="text/javascript">
function cal(ida,idb,idc,idd)
{
var numb=Number(document.getElementById(idb).value);
var numc = Number(document.getElementById(idc).value);
var numd = Number(document.getElementById(idd).value);
var numa=numb+numc-numd
document.getElementById(ida).value=numa;
}
</script>
<input type="text" id="numa" name="numa" onkeyup="cal('numa','numb','numc','numd')" />=
<input type="text" id="numb" name="numb" onkeyup="cal('numa','numb','numc','numd')" />+
<input type="text" id="numc" name="numc" onkeyup="cal('numa','numb','numc','numd')" />-
<input type="text" id="numd" name="numd" onkeyup="cal('numa','numb','numc','numd')" />
截图如下: