Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Js calculation value division
Js calculation value division
The function velocity = (distance, time CNT) {should be changed to function velocity (distance, time CNT){, that is to say, there is an equal sign in the middle.

This procedure is the simplest, but it is not friendly enough and rigorous enough. I'll help you change it. You can save the following code as. Html file and open it with ie.

& lthtml & gt

& lthead & gt

& lttitle & gt& lt/title & gt;

& lt scripting language = "javascript">

Function speed () {

var distance = document . getelementbyid(' id instance ');

var time CNT = document . getelementbyid(' itime CNT ');

if (isNaN(distance.value)) {

Alert ('Length must be numeric!' );

distance . focus();

Return;

}

if (isNaN(timecnt.value)) {

Alert ('Time must be a number!' );

time CNT . focus();

Return;

}

if (timecnt.value == 0) {

Alert ('Time cannot be 0!' );

time CNT . focus();

Return;

}

document . getelementbyid(' s value ')。 innerText = distance . value/time CNT . value;

}

& lt/script & gt;

& lt/head & gt;

& ltbody & gt

length < input type = ' text ' name = ' I instance ' id = ' I instance ' value = ' '/& gt; & ltbr/>;

time

& ltinput type = ' button ' value = ' calculation ' onclick = ' velocity()'/& gt; & ltbr/>; & ltbr/>;

Calculation result:

& lt/body & gt;

& lt/html & gt;