应朋友需要制作的一个小页面
<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" οnkeyup="cal('numa','numb','numc','numd')" />= <input type="text" id="numb" name="numb" οnkeyup="cal('numa','numb','numc','numd')" />+ <input type="text" id="numc" name="numc" οnkeyup="cal('numa','numb','numc','numd')" />- <input type="text" id="numd" name="numd" οnkeyup="cal('numa','numb','numc','numd')" />
截图如下: