有关javascript 里的Math的使用.
2009-09-02 14:12
344 查看
Code
<!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>
<title>Untitled Page</title>
<script type="text/javascript">
///计算三角函数的的
function resule() {
var longBorder = new Number(document.getElementById("longBorder").value);
var shortBorder = new Number(document.getElementById("shortBorder").value);
var resuleConValue = new Number();
resuleConValue = Math.atan2(shortBorder, longBorder);
angle = resuleConValue * (180 / Math.PI);
document.getElementById("resultCon").value = angle
}
</script>
</head>
<body>
<p>
长边:<input type="text" id="longBorder" />
</p>
<p>
短边:<input type="text" id="shortBorder" />
</p>
<p>
结果:<input type="text" id="resultCon" />
</p>
<input type="button" value="计算" onclick="resule();" />
</body>
</html>
document.getElementById("longBorder").value
才是获取文本框里面的值..
而document.getElementById("longBorder")
是获取值里的对象.
<!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>
<title>Untitled Page</title>
<script type="text/javascript">
///计算三角函数的的
function resule() {
var longBorder = new Number(document.getElementById("longBorder").value);
var shortBorder = new Number(document.getElementById("shortBorder").value);
var resuleConValue = new Number();
resuleConValue = Math.atan2(shortBorder, longBorder);
angle = resuleConValue * (180 / Math.PI);
document.getElementById("resultCon").value = angle
}
</script>
</head>
<body>
<p>
长边:<input type="text" id="longBorder" />
</p>
<p>
短边:<input type="text" id="shortBorder" />
</p>
<p>
结果:<input type="text" id="resultCon" />
</p>
<input type="button" value="计算" onclick="resule();" />
</body>
</html>
document.getElementById("longBorder").value
才是获取文本框里面的值..
而document.getElementById("longBorder")
是获取值里的对象.
相关文章推荐
- 有关javascript 里的Math的使用.
- 有关html5、javascript工具、css框架以及jquery插件的前端专题,收藏以供今后使用
- JavaScript中的Math 使用介绍
- 有关javascript中的JSON.parse和JSON.stringify的使用一二
- Javascript 找一组数字中的最大数的方法(附使用Math.max来检测浏览器支持哪个属性)
- JavaScript中的Math.E属性使用详解
- 介绍JavaScript中Math.abs()方法的使用
- JavaScript中使用Math.floor()方法对数字取整
- JavaScript中的Math.sin()方法使用详解
- JavaScript中使用指数方法Math.exp()的简介
- JavaScript中的Math.SQRT1_2属性使用简介
- 简介JavaScript中Math.cos()余弦方法的使用
- JavaScript中使用指数方法Math.exp()的简介
- Javascript四舍五入Math.round()与Math.pow()使用介绍
- Javascript四舍五入Math.round()与Math.pow()使用介绍
- 使用math.js进行javascript精确计算
- javascript中Math.random()使用详解
- JavaScript中的Math.SQRT1_2属性使用简介
- JavaScript中的Math.sin()方法使用详解
- javascript Math.random的使用