<script type="text/javascript">
var f;
var fuhao;
function out(num) {
document.getElementById("txtword").value += num;// 吧相应的数字显示在文本框中
}
function outer(fu) { //返回相应的运算符号,用以在等号里判断
f = document.getElementById("txtword").value;
document.getElementById("txtword").value = "";
fuhao = fu;
return fuhao;
}
function clear1() { // 清除所有数据!
document.getElementById("txtword").value = "";
}
function subss() {
var t = document.getElementById("txtword");
t.value = t.value.substring(0, t.value.length - 1);
}
function equal() { //等号里的判断!
if (fuhao == '+') {
document.getElementById("txtword").value = parseFloat(f) + parseFloat(document.getElementById("txtword").value);
}
else if (fuhao == '-') {
document.getElementById("txtword").value = parseFloat(f) - parseFloat(document.getElementById("txtword").value);
}
else if (fuhao == '*') {
document.getElementById("txtword").value = parseFloat(f) * parseFloat(document.getElementById("txtword").value);
}
else if (fuhao == '/') {
document.getElementById("txtword").value = parseFloat(f) /parseFloat(document.getElementById("txtword").value);
}
}
</script>