写一个html网页,包含两个输入框和一个按钮,在第一个输入框输入表达式如“1+3”、“2*4”等等表达式后点击按钮,第二个输入框显示表达式计算结果。
请高手帮忙,谢谢。
请高手帮忙,谢谢。
解决方案 »
- 一个简单ssh2 hibernate问题
- 两个 int 类型怎么比较?
- 一个关于jsp中include指令很奇怪的问题
- 求助JSP 虚拟主机上做上传文件操作
- myeclipse+weblogic9,每次一改代码就重启weblogic,如何设置不重启。
- hib批量插入数据导致到主机的TCP/IP连接失败
- eclipse连mysql问题...急
- 我的WEBLOGIC单独启动一切都好,可是如果在JB里启动后
- java.lang.NullPointerException这个异常是什么意思??
- jquery获取同行的第一个td里的内容
- 在Myeclipse中项目导出遇到麻烦了!
- spring mvc中视图技术获取session值问题
<html>
<head><title></title></head>
<script>
function calc(){
var expression = document.getElementById("expre").value;
var result = eval(expression);
document.getElementById("result").value=result;
}
</script> <body>
<input type="text" id="expre"> <input type="button" onclick="calc()" value="给我结果"><br>
<input type="text" id="result">
</body>
</html>用notepad一次打成功了,来点掌声
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head><style>
</style>
</head>
<body>
<div>
简单表达式:
<input type="text" id="1" style="background-color:grey;color:red"/>
<br/>
<input type="button" value="点击显示计算结果:" onclick="count()"/>
<input type="text" id="2" style="background-color:yellow;color:red"/>
</div>
<script>
function count(){
var t1=document.getElementById("1").value;
document.getElementById("2").value=eval(t1);
}
</script>
</body>
</html>