<!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> <script type="text/javascript"> function ys(){ var y=document.getElementById("yi").value; var e=document.getElementById("er").value; var ee=document.getElementById("dd").value; var s=""; switch(ee) { case "加": s=parseInt(y)+parseInt(e); break; case"减": s=parseInt(y)-parseInt(e); break; case"乘": s=parseInt(y)*parseInt(e); break; default: s=parseInt(y)/parseInt(e); } document.getElementById("san").value=s; } </script> </head> <body> <input id="yi" type="text" /> <select id="dd"> <option value="加">+</option> <option value="减">-</option> <option value="乘">*</option> <option value="除">/</option> </select> <input id="er" type="text" /> <input value="=" type="button" onclick="ys()" /> <input id="san" type="text" /> </body> </html>
慕UI8820655
lllqw
相关分类