Home  >  Q&A  >  body text

Why does the calculation not display the results?

<!doctype html>

<html>

<head>

<meta charset="utf-8 ">

<title>Untitled Document</title>

<style>

section{

background-color:# c9e495;

width:280px;

height:330px;

text-align:center;

padding-top:1px;}

.textBaroder{

border-width:1px;

border-style:solid;}

</style>

< /head>

<body>

<section>

<h1>

<img src= "image/logo.jpg" width="260" height="31">Welcome to Taobao!

</h1>

<form action="" method="post" name="myform" id="myform">

<h3> ;

<img src="file:///F|/17webpage/computer/image/shopping cart.jpg" width="54" height="54">Shopping simple calculator

</h3>

The first number<input name="txtNum1" type="text" class="textBaroder" id="txtNum1" size="25 ">

The second number<input name="txtNum2" type="text" class="textBaroder" id="txtNum2" size="25">

<input name="addButton2" type="button" id="addButton2" value=" " onChange="compute(' ')">

<input name="subButton2" type="button" id="subButton2" value=" - " onChange="compute('-')">

<input name="mulButton2" type ="button" id="mulButton2" value=" × " onChange="compute('*')">

<input name="divButton2" type="button" id="divButton2" value=" ÷ " onChange="compute('/')">

Computation result<INPUT name="textResult" type="text" class="textBaroder" id ="textResult" size="25">

</form>

</section>

<script>

function compute(op)

{

var num1,num2;

num1 = oarseFloat(document.myform .txtNum1.value);

num2 = oarseFloat(document.myform.txtNum2.value);

if (op==" ")

document.myform.txtResult .value = num1 num2;

if (op=="-")

document.myform.txtResult.value = num1-num2;

if (op== "*")

document.myform.txtResult.value = num1*num2;

if (op=="/" && num2!=0)

document. myform.txtResult.value = num1/num2;

}

</script>

</body>

</html>

BBBB959 days ago991

reply all(3)I'll reply

  • 雪了无痕

    雪了无痕2021-11-10 11:05:16

    http://b68z56d.cn/Liangqiu Jingzhi Information Network is released

    reply
    0
  • 小晴子

    小晴子2021-11-10 10:04:06

    http://sn4r209.cn/Chunyu Jifeng Information Network Renewal

    reply
    0
  • autoload

    autoload2021-10-29 10:48:45

    1.oarseFloat? parseFloat? It’s really confusing. 2. There is another problem, txtResult is wrong. 3. Can onChange be used? Replace with onclick

    reply
    2
  • Cancelreply