<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <title>计算器</title> <mce:style type="text/css"><!-- /*细边框的文本输入框*/ .textBaroder { border-width:1px; border-style:solid } --></mce:style><mce:style type="text/css" mce_bogus="1"><!-- /*细边框的文本输入框*/ .textBaroder { border-width:1px; border-style:solid } --></mce:style><style type="text/css" mce_bogus="1" mce_bogus="1">/*细边框的文本输入框*/ .textBaroder { border-width:1px; border-style:solid } </style> <mce:script type="text/javascript"><!-- function Add() { var n1=parseFloat(document.getElementById("txtNum1").value); var n2=parseFloat(document.getElementById("txtNum2").value); document.getElementById("txtResult").value=(n1+n2); } function Sub() { var n1=parseFloat(document.getElementById("txtNum1").value); var n2=parseFloat(document.getElementById("txtNum2").value); document.getElementById("txtResult").value=(n1-n2); } function Mul() { var n1=parseFloat(document.getElementById("txtNum1").value); var n2=parseFloat(document.getElementById("txtNum2").value); document.getElementById("txtResult").value=(n1*n2); } function Div() { var n1=parseFloat(document.getElementById("txtNum1").value); var n2=parseFloat(document.getElementById("txtNum2").value); if(n2==0) alert("除数不能为0"); else document.getElementById("txtResult").value=(n1/n2); } // --></mce:script> </head> <body> <img src="images/logo.gif" mce_src="images/logo.gif" width="240" height="31" alt="图片无法显示" /> <p> 欢迎您来淘宝!</p> <form action="" method="post" id="myform"> <table border="0" bgcolor="#C9E495" align="center"> <tr> <td colspan="4"> <h3> <img src="images/shop.gif" mce_src="images/shop.gif" width="54" height="54" alt="无法显示" /> 购物简易计算器</h3> </td> </tr> <tr> <td> 第一个数</td> <td colspan="3"> <input name="txtNum1" type="text" class="textBaroder" id="txtNum1" size="25" /></td> </tr> <tr> <td> 第二个数</td> <td colspan="3"> <input name="txtNum2" type="text" class="textBaroder" id="txtNum2" size="25" /></td> </tr> <tr> <td> <input name="addButton2" type="button" id="addButton2" οnclick="Add();" value=" + " /></td> <td> <input name="subButton2" type="button" id="subButton2" οnclick="Sub();" value=" - " /></td> <td> <input name="mulButton2" type="button" id="mulButton2" οnclick="Mul();" value=" × " /></td> <td> <input name="divButton2" type="button" id="divButton2" οnclick="Div();" value=" ÷ " /></td> </tr> <tr> <td> 计算结果</td> <td colspan="3"> <input name="txtResult" type="text" class="textBaroder" id="txtResult" size="25" /></td> </tr> </table> </form> </body> </html>