javascript基础-实现简单功能
2016-07-30 10:46
441 查看
静态页面
(1)打印菱形,并将系统时间打印出来
动态页面
(1)计算个人所得税
[code=html;toolbar:false"><!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function show(){
var txta=document.getElementById("txt1");
var txtb=document.getElementById("txt2");
var txtc=document.getElementById("txt3");
if(txta.value>txtb.value){
txtc.value=(txta.value-txtb.value)*0.1;
}else{
txtc.value=0;
}
}
function rewrite(){
var txta=document.getElementById("txt1").value="";
var txtb=document.getElementById("txt2").value="";
var txtc=document.getElementById("txt3").value="";
}
show();
</script>
</head>
<body>
<table width="419" border="1">
<tr>
<td colspan="2"><div align="center">个人所得税计算器</div></td>
</tr>
<tr>
<td width="189"><div align="left">请输入你的月收入:</div></td>
<td width="214"><input id="txt1" name="txt1" type="text" />
元</td>
</tr>
<tr>
<td><div align="left">请输入所得税起征额:</div></td>
<td><input id="txt2" name="txt2" type="text" />
元</td>
</tr>
<tr>
<td>所得税:</td>
<td><input id="txt3" name="txt3" type="text" />
元</td>
</tr>
<tr>
<td colspan="2">
<center>
<button name="btn1" value="计算" type="button" onclick="show()">计算
</button>
<button name="btn2" value="重填" type="button" onclick="rewrite()">重填
</button></td>
</center>
</tr>
</table>
</body>
</html>
(1)打印菱形,并将系统时间打印出来
(2)打印乘法口诀表<!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> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>无标题文档</title> <script language="javascript" type="text/javascript"> function Demo(){ for(i=1;i<=9;i++){ for(j=1;j<=i;j++){ document.write(i+"*"+j+"="+i*j+" "); } document.write("<br>"); } } Demo(); </script> </head> <body> </body> </html>
动态页面
(1)计算个人所得税
[code=html;toolbar:false"><!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<script>
function show(){
var txta=document.getElementById("txt1");
var txtb=document.getElementById("txt2");
var txtc=document.getElementById("txt3");
if(txta.value>txtb.value){
txtc.value=(txta.value-txtb.value)*0.1;
}else{
txtc.value=0;
}
}
function rewrite(){
var txta=document.getElementById("txt1").value="";
var txtb=document.getElementById("txt2").value="";
var txtc=document.getElementById("txt3").value="";
}
show();
</script>
</head>
<body>
<table width="419" border="1">
<tr>
<td colspan="2"><div align="center">个人所得税计算器</div></td>
</tr>
<tr>
<td width="189"><div align="left">请输入你的月收入:</div></td>
<td width="214"><input id="txt1" name="txt1" type="text" />
元</td>
</tr>
<tr>
<td><div align="left">请输入所得税起征额:</div></td>
<td><input id="txt2" name="txt2" type="text" />
元</td>
</tr>
<tr>
<td>所得税:</td>
<td><input id="txt3" name="txt3" type="text" />
元</td>
</tr>
<tr>
<td colspan="2">
<center>
<button name="btn1" value="计算" type="button" onclick="show()">计算
</button>
<button name="btn2" value="重填" type="button" onclick="rewrite()">重填
</button></td>
</center>
</tr>
</table>
</body>
</html>
相关文章推荐
- Javascript 严格模式详解
- js 字符串转换成int或者float类型
- JavaScript学习笔记
- js数组
- js split函数用法总结
- web框架学习前复习——jsDom
- javascript回到顶部特效
- c json解析jansson
- JavaScript:exec()方法的用法及说明
- JavaScript概述
- js实现继承的三种方式
- JSP/SERVLET入门教程--Servlet 使用入门
- javascript鼠标滑过显示二级菜单特效
- Js中 call、aplly的使用和拓展
- javaScript 时间日期对比
- json数据格式 与 for in
- js数组的操作
- js正则表达式用法大全
- js点击按钮,放大对应图片代码
- jsp:forward跳转action 404错误