<!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>

DIV隐藏与重显的更多相关文章

  1. 点击一个div隐藏另一个div

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  2. JS控制DIV隐藏显示

    转载自:http://blog.sina.com.cn/s/blog_6c3a67be0100ldbe.html JS控制DIV隐藏显示 一,需求描述: 现在有3个DIV块,3个超链接,需要点击一个链 ...

  3. jQuery实现鼠标点击div外的地方div隐藏消失的效果(转)

    转:https://www.cnblogs.com/jsingleegg/p/3456152.html css部分: <style type="text/css">.p ...

  4. 常见问题1:默认div隐藏,点击按钮时出现,再点击时隐藏。

    例:默认div隐藏,点击按钮时出现,再点击时隐藏. <a href="#" onclick="f('ycbc')"; >控制按钮</a> ...

  5. jQuery实现鼠标点击div外的地方div隐藏消失的效果

    css部分: <style type="text/css"> .pop { width:200px; height:130px; background:#080;} & ...

  6. 设置一个div网页滚动时,使其固定在头部,当页面滚动到距离头部300px时,隐藏该div,另一个div在底部,此时显示;当页面滚动到起始位置时,头部div出现,底部div隐藏

    设置一个div网页滚动时,使其固定在头部,当页面滚动到距离头部300px时,隐藏该div,另一个div在底部,此时显示: 当页面滚动到起始位置时,头部div出现,底部div隐藏 前端代码: <! ...

  7. Html 使用技巧 -- 设置display属性可以使div隐藏后释放占用的页面空间

         div的visibility可以控制div的显示和隐藏,但是隐藏后页面显示空白: style="visibility: none;" document.getElemen ...

  8. div 隐藏和显示

    转自:http://aideehorn.iteye.com/blog/417558 div的visibility可以控制div的显示和隐藏,但是隐藏后页面显示空白: style="visib ...

  9. div隐藏与显示

    <input type="button" value="隐藏详情" class="jishu_n_k1_input2" id=&quo ...

随机推荐

  1. BFS 10.1.5.253 1502

    http://10.1.5.253/acmhome/problemdetail.do?&method=showdetail&id=1502 //1502 #include <st ...

  2. tomcat中debug启动和start启动的区别

    debug启动tomcat:修改代码不加方法,不加参数,只是单纯的修改方法,不用重启tomcat(热部署). start启动tamcat:修改代码需要重启tomcat.

  3. linux 挂载ISO

    首先,将作为源的iso的挂载到系统上. 代码如下: mount -o loop /xxx/xxx.iso /mnt/iso/ 其中/mnt/iso是事先在本地建立的文件夹. 然后将文件iso.repo ...

  4. JAVA的可变类与不可变类

    转自: http://www.blogjava.net/hilor/articles/150610.html 可变类和不可变类(Mutable and Immutable Objects)的初步定义: ...

  5. .NET 基础 一步步 一幕幕[面向对象之new、this关键字]

    经常会有人问:小伙子,有没有对象啊,要不要大叔我帮你介绍一个啊,小伙子会说:大叔,不用我自己new一个就好了.(PS:活该你没有对象) 上边当然是一个段子咯,程序员那会没有对象,自己new一个就有了啊 ...

  6. LibreOffice连接orcle 11g

    1.安装java 2.安装JDBC 官网下载 复制到/usr/java/jdk1.8.0_111/jre/lib/ext文件下

  7. Linux下tomcat使用

    http://tomcat.apache.org/download-70.cgi这里下载 放到Linux目录下,解压开, 默认port:8080能够直接使用 经常使用启动命令catalina.sh   ...

  8. android 窗体透明的,黑暗度等的设置技巧

    设置透明度(这是窗体本身的透明度,非背景) 1 WindowManager.LayoutParams lp=getWindow().getAttributes(); 2 lp.alpha=0.3f; ...

  9. qt优点

    (1)优良的跨平台特性.  Qt支持下列操作系统:Microsoft Windows 95/98.Microsoft Windows NT.Linux.Solaris.SunOS.HP-UX.Digi ...

  10. dede当前位置各种写法

    方法一.Dedecms当前位置{dede:field name='position'/} 方法二.dede:field name='position' runphp='yes'}          $ ...