标签:ext var get utf-8 nload type put ntb click
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript">
onload = function() {
document.getElementById(‘add‘).onclick = function(){
var iNum1 = document.getElementById(‘Num1‘).value;
var iNum2 = document.getElementById(‘Num2‘).value;
var iNum = parseInt(iNum1) + parseInt(iNum2);
// alert(iNum);
var onThree = document.getElementById(‘Num3‘);
onThree.value = iNum;
}
document.getElementById(‘sub‘).onclick = function(){
var iNum1 = document.getElementById(‘Num1‘).value;
var iNum2 = document.getElementById(‘Num2‘).value;
var iNum = parseInt(iNum1) - parseInt(iNum2);
// alert(iNum);
var onThree = document.getElementById(‘Num3‘);
onThree.value = iNum;
}
document.getElementById(‘mul‘).onclick = function(){
var iNum1 = document.getElementById(‘Num1‘).value;
var iNum2 = document.getElementById(‘Num2‘).value;
var iNum = parseInt(iNum1) * parseInt(iNum2);
// alert(iNum);
var onThree = document.getElementById(‘Num3‘);
onThree.value = iNum;
}
document.getElementById(‘divi‘).onclick = function(){
var iNum1 = document.getElementById(‘Num1‘).value;
var iNum2 = document.getElementById(‘Num2‘).value;
var iNum = parseInt(iNum1) / parseInt(iNum2);
// alert(parseInt(iNum));
var onThree = document.getElementById(‘Num3‘);
onThree.value = iNum;
}
}
</script>
</head>
<body>
<!--输入框-->
<input type="text" name="Num1" id="Num1" value="" />
<input type="text" name="Num2" id="Num2" value="" /> =
<input type="text" name="num1" id="Num3" value="" />
<br />
<!--运算符-->
<input type="button" name="add" id="add" value="+" />
<input type="button" name="sub" id="sub" value="-" />
<input type="button" name="mul" id="mul" value="*" />
<input type="button" name="divi" id="divi" value="/" />
</body>
</html>
标签:ext var get utf-8 nload type put ntb click
原文地址:http://www.cnblogs.com/rxl1003/p/6628447.html