<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="zxn">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>Java完整程序</title>
<script language="JavaScript">
<!--
//单击性别按钮
function clickSex(ctype){
alert("--13--");
//如果选择了男
if(ctype=="man")
{
document.getElementById("man").style.display="block";
document.getElementById("miss").style.display="none";
}
if(ctype=="miss")
{
document.getElementById("man").style.display="none";
document.getElementById("miss").style.display="block";
}
}
//获得结果
function getResult(){
var sex1=document.getElementById("sex1").checked;
var sex2=document.getElementById("sex2").checked;
var yourmoney=document.getElementById("yourmoney").value;
var yoursmoke=document.getElementById("yoursmoke").value;
var yourwine=document.getElementById("yourwine").value;
var yourface=document.getElementById("yourface").value;
var yourclothe=document.getElementById("yourclothe").value;
var result=0;
if(sex1==true){
result=yourmoney-yoursmoke-yourwine;
}
if(sex2==true){
result=yourmoney-yourface-yourclothe;
}
return result;
}
//格式化输出
function outPrint(name,age,money,result)
{
var str="您好"+name+"<br>您现在"+age+"岁<br>您的月收入为:"+money+"<br>根据您的的月结余为:"
+result+"<br>谢谢参与!";
document.writer(str);
}
//确认提交
function isOk(){
return confirm("是否确认提交数据?"点【确认】提交,点【取消】放弃);
}
//主函数
function mainClick(){
var isok=isOk();
if(isok==true){
var yourname=document.getElementById("yourname").value;
var yourage=document.getElementById("yournage").value;
var yourmongey=document.getElementById("yourmongey").value;
var yourresult=getResult();
outPrint(yourname,youage,yourmoney,yourresult);
}
}
//-->
</script>
</head>
<body>
<form name="myform">
性别:<input type="radio" id="sex1" name="sex" value="先生" οnclick="clickSex('man')" >男
<input type="radio" id="sex2" name="sex" value="女士" οnclick="clickSex('miss')" >女<br/>
姓名:</br>
<input type="text" id="yourname" name="yourname" value=""><br/>
年龄:<br/>
<input type="text" id="yourage" name="yourage" value=""><br/>
月收入:<br/>
<input type="text" id="yourmoney" name="yourmoney" value=""><br/>
<div id="man" style="display:none">
月抽烟消费:</br>
<input type="text" id="yoursmoke" name="yoursmoke" value=""><br/>
月喝酒消费:</br>
<input type="text" id="yourwine" name="yourwine" value=""><br/>
</div>
<div id="miss" style="display:none">
月美容消费: </br>
<input type="text" id="yourface" name="yourface" value=""><br/>
月购置衣物花费:<br/>
<input type="text" id="yourclothe" name="yourclothe" value=""><br/>
</div>
<hr>
<input type="button" value="提交" οnclick="mainClick()">
<input type="reset" value="重填">
</hr>
</form>
</body>
</html>
javaScript 隐藏计算
最新推荐文章于 2019-08-01 21:03:00 发布