<div class="codetitle"> <span><a style="CURSOR: pointer" data="85869" class="copybut" id="copybut85869" onclick="doCopy('code85869')"><u>复代码码</u></a></span> 代码如下:</div> <div class="codebody" id="code85869"> <br><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 전환//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br> <html xmlns="http://www.w3.org/ 1999/xhtml"><br> <head><br><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><br><title>计算器</title><br><script 언어="javascript" type="text/javascript"><br> varclearFlag=false;<br> function getNum(num){<br> //alert( num);<br> var objresult=document.getElementById("result");<br> if(clearFlag){<br> objresult.value="";<br> clearFlag=false;<br> }<br> //alert(objresult);<br> objresult.value =num;<br> }<br>function getResult(){<br> var objresult=document.getElementById("result");<br> objresult.value= objresult.value "=" eval(objresult.value);<br> clearFlag=true;<br>}<br></script><br></head><br><body><br> <table width="200" border="1" cellpadding="2"><br> <tr><br> <td colspan="4"><input type="text" name= "result" id="result" size="33"></td><br> </tr><br> <tr><br> <td width="56">< input type="button" value=" 1 " onclick="getNum(1)"></td><br> <td width="56"><input type="button" value=" 2 " onclick="getNum(2)"></td><br> <td width="51"><input type="button" value=" 3 " onclick="getNum(3) "></td><br> <td width="58"><input type="button" value=" " onclick="getNum(' ')"></td><br> </tr><br> <tr><br> <td><input type="button" value=" 4 " onclick="getNum(4)"></td><br> <td><input type="button" value=" 5 " onclick="getNum(5)"></td><br> <td><input type="button" 값 =" 6 " onclick="getNum(6)"></td><br> <td><input type="button" value=" - " onclick="getNum('-')"> ;</td><br> </tr><br> <tr><br> <td><input type="button" value=" 7 " onclick="getNum(7)"> ;</td><br> <td><input type="button" value=" 8 " onclick="getNum(8)"></td><br> <td>< input type="button" value=" 9 " onclick="getNum(9)"></td><br> <td><input type="button" value=" * " onclick="getNum ('*')"></td><br> </tr><br> <tr><br> <td><input type="button" value=" 0 " onclick= "getNum(0)"></td><br> <td><input type="button" value=" . " onclick="getNum('.')"></td><br> <td><input type="button" value=" = " onclick="getResult()"></ td><br> <td><input type="button" value=" / " onclick="getNum('/')"></td><br> </tr><br> </table><br></body><br></html><br> </div>