首页 > 网站 > WEB开发 > 正文

DIV隐藏与重显

2024-04-27 14:20:46
字体:
来源:转载
供稿:网友

DIV隐藏与重显

<!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 type="text/javascript"><!--function clickSex(ctype){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 isOK(){return confirm("是否确认提交数据?");}

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.write(str);}function mainClick(){var isok=isOK();if(isok==true){var yourname=document.getElementById("yourname").value;var yourage=document.getElementById("yourage").value;var yourmoney=document.getElementById("yourmoney").value;var yourresult=getResult();outPrint(yourname,yourage,yourmoney,yourresult);}}

//--></script>

</head>

<body>

<form name="myform">性别:<input type="radio" id="sex1" name="sex" value="先生" onclick="clickSex('man')">男&nbsp&nbsp;<input type="radio" id="sex2" name="sex" value="小姐" onclick="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/><hr/></div><input type="button" value="提交" onclick="mainClick()"><input type="reset" value="重填"></form>

</body></html>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表