所以我试图制作一个在线计算器并制作了一个js脚本我的问题是如何将此脚本添加到我的html中我尝试使用脚本但它没有做任何事情
function motion1() {
var right=0;
var initvel = calc.initvel.value;
var finalvel = calc.finalvel.value;
var time = calc.time.value;
var accl = calc.accl.value;
var dist = calc.dist.value;
var complete="you have entered more than 3 values. Please leave two text box empty. Other two text box will be calculated based on that";
var incomplete="Sorry! incomplete information";
var validinput="You have not entered numeric values!!";
if (isNaN(calc.initvel.value)) return alert(validinput);
if (isNaN(calc.finalvel.value)) return alert(validinput);
if (isNaN(calc.time.value)) return alert(validinput);
if (isNaN(calc.accl.value)) return alert(validinput);
if (isNaN(calc.dist.value)) return alert(validinput);
if(initvel!="" && finalvel!="" && time!="" && accl !="" ) return alert(complete);
if(initvel!="" && finalvel!="" && time!="" && accl !="" && dist !="" ) return alert(complete);
if(initvel!="" && finalvel!="" && time!="" ){
accl=(finalvel-initvel)/time;
calc.dist.value= initvel*time + .5*accl*time*time;
calc.accl.value=accl
right++;}
if(initvel!="" && finalvel!="" && accl!="" ){
time=(finalvel-initvel)/accl;
calc.dist.value= initvel*time + .5*accl*time*time;
calc.time.value=time
right++;}
if(initvel!="" && time!="" && accl!="" ){
initvel=parseFloat(initvel);
calc.finalvel.value=initvel + (accl*time);
calc.dist.value= initvel*time + .5*accl*time*time;
right++;}
if(finalvel!="" && time!="" && accl!="" ){
initvel=finalvel - (accl*time);
calc.dist.value= initvel*time + .5*accl*time*time;
calc.initvel.value=initvel
right++;}
if(dist!="" && time!="" && accl!="" ){
initvel=(dist - .5*accl*time*time )/time;
calc.finalvel.value= initvel*time + accl*time;
calc.initvel.value=initvel
right++;}
这是牛顿运动学方程计算器,如果它有任何帮助,它应该看起来像这样, 在此处输入图像描述
所以它会问我这个值,它应该能够解决其他领域
泛舟湖上清波郎朗
慕的地10843
HUX布斯
相关分类