js制作简单的计算器
学着做了一个简单的计算器!记录记录!哈哈
<!DOCTYPE html>
<html>
<head>
<title>简单的计算器</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
input{width:100%}
</style>
</head>
<body>
<script type="text/javascript">
function compute(obj)
{
obj.expr.value=eval(obj.expr.value)
}
var plus="+";
var minus="-";
var multiply="*";
var divide="/";
var decimal=".";
function enter(obj,string)
{
obj.expr.value+=string;
}
function cle(obj)
{
obj.expr.value='';
}
</script>
<form >
<table border=1>
<tr >
<td colspan="4"><input type="text" name="expr" size="30" style="width:97%"></td>
</tr>
<tr>
<td><input type="button" value="7" onclick="enter(this.form,7)"></td>
<td><input type="button" value="8" onclick="enter(this.form,8)"></td>
<td><input type="button" value="9" onclick="enter(this.form,9)"></td>
<td><input type="button" value="/" onclick="enter(this.form,divide)"></td>
</tr>
<tr>
<td><input type="button" value="4" onclick="enter(this.form,4)"></td>
<td><input type="button" value="5" onclick="enter(this.form,5)"></td>
<td><input type="button" value="6" onclick="enter(this.form,6)"></td>
<td><input type="button" value="*" onclick="enter(this.form,multiply)"</td>
</tr>
<tr>
<td><input type="button" value="1" onclick="enter(this.form,1)"></td>
<td><input type="button" value="2" onclick="enter(this.form,2)"></td>
<td><input type="button" value="3" onclick="enter(this.form,3)"></td>
<td><input type="button" value="-" onclick="enter(this.form,minus)"></td>
</tr>
<tr>
<td colspan="2"><input type="button" value="0" onclick="enter(this.form,0)"></td>
<td><input type="button" value="." onclick="enter(this.form,decimal)"></td>
<td><input type="button" value="+" onclick="enter(this.form,plus)"></td>
</tr>
<tr>
<td colspan="2" ><input type="button" value="=" onclick="compute(this.form)" ></td>
<td colspan="2"><input type="button" value="AC" size=3 onclick="cle(this.form)"></td>
</tr>
</table>
</form>
</body>
</html>
js制作简单的计算器的更多相关文章
- JS——制作简单的网页计算器
		
用JS做了一个简易的网页计算器 <!DOCTYPE html> <html lang="en"> <head> <meta charset ...
 - 用JavaScript制作简单的计算器
		
<html > <head> <title>简单计算器</title> <style type="text/css"> ...
 - 【前端】Vue.js实现简单价格计算器
		
价格计算器 实现效果: 实现代码及注释: <!DOCTYPE html> <html> <head> <title>价格计算器</title> ...
 - d3.js 制作简单的俄罗斯方块
		
d3.js是一个不错的可视化框架,同时对于操作dom也是十分方便的.今天我们使用d3.js配合es6的类来制作一个童年小游戏--俄罗斯方块.话不多说先上图片. 1. js tetris类 由于方法拆分 ...
 - d3.js 制作简单的贪吃蛇
		
d3.js是一个不错的可视化框架,同时对于操作dom也是十分方便的.今天我们使用d3.js配合es6的类来制作一个童年小游戏–贪吃蛇.话不多说先上图片. 1. js snaker类 class Sna ...
 - 利用css+原生js制作简易钟表
		
利用css+原生js制作简单的钟表.效果如下所示 实现该效果,分三大块:html.javascript.css html部分html部分比较简单,定义一个clock的div,内部有原点.时分秒针.日期 ...
 - JS制作图片切换
		
<!DOCTYPE html> <html> <head> <title>纯JS制作简单的图片切换</title> <meta cha ...
 - 留念 C语言第一课简单的计算器制作
		
留念 C语言第一课简单的计算器制作 学C语言这么久了. /* 留念 C语言第一课简单的计算器制作 */ #include<stdio.h> #include<stdlib.h ...
 - JS实现一个简单的计算器
		
使用JS完成一个简单的计算器功能.实现2个输入框中输入整数后,点击第三个输入框能给出2个整数的加减乘除.效果如上: 第一步: 创建构建运算函数count(). 第二步: 获取两个输入框中的值和获取选择 ...
 
随机推荐
- ASP DropDownList部分选项无法触发回传问题
			
今天偶然碰到这个问题,一个通过后台绑定的DropDownList控件出现部分选项触发事件,部分选项不触发事件的问题: 原因是多个OPTION的Value值一致,导致ASP事件注册失败,只要在绑定过程中 ...
 - Makefile编译库
			
funs.h: #ifndef __FUNS_H__ #define __FUNS_H__ void fun1(); #endif funs.c #include "funs.h" ...
 - Avg_row_length是怎么计算的?
			
通过一下命令我们可以获取表的使用情况: root::>show table status like 'tbname'\G 结果: . row ************************** ...
 - wex5 实战 框架拓展之1 公共data组件(Data)
			
一 前言 wex5作为开发利器,框架本身的集成能力与拓展能力可谓简单强大.在学习过程中,对框架的拓展能力,需要通过实践来丰富.今天,我以实际工作中的实例,先来看一看,框架上的公共data组件的实现与用 ...
 - Django(二)
			
一.路由系统,URL 1.url(r'^index/', views.index), url(r'^home/', views.Home.as_view()), 2. ...
 - 10-8位7段数码管驱动实验——小梅哥FPGA设计思想与验证方法视频教程配套文档
			
芯航线--普利斯队长精心奉献 实验目的: 1.实现FPGA驱动数码管动态显示: 2.使用In system sources and probes editor工具,输入需要显示在数码管上的的数据, ...
 - MySQL时间段查询
			
现实中我们会遇到统计报表.比如查询当月每一天的数据数量...等等之类的.以下内容就是有关这方面的咯. 首先要知道几个函数 mysql> select now(); //这个是显示的当前时间 +- ...
 - AChecker + Selenium2对需要登录的页面进行自动化可访问性测试
			
前言:这段时间还算比较空闲,我准备把过去做过的有些形形色色,甚至有些奇怪的研究总结一下,也许刚好有人用的着也不一定,不枉为之抓耳挠腮的时光和浪费的电力. 名词解释: 网站可访问性测试:国内基本没有 ...
 - HDU 1525 Euclid's Game 博弈
			
Euclid's Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Tot ...
 - ionic 中$ionicView.beforeEnter 事件的一个bug
			
我在使用ionic写app的时候,需要使用$IonicView.beforeEnter事件,在页面进入前做一些事情,但是发现,它不起作用,很蛋疼,后来,看了别人做的app例子,也涉及到这个$Ionic ...