<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
<style>
body {
margin: 0;
padding: 0;
font-family: '微软雅黑';
}
form {
border: 1px solid #eee;
border-radius: 10px;
width: 600px;
margin: 50px auto;
padding: 20px;
line-height: 28px;
position: relative;
}
form label {
display: block;
font-weight: bold;
padding: 10px 0;
}
form input {
margin-left: -3px;
margin-right: 5px;
}
#showbox1, #showbox2 {
border: 1px solid #eee;
width: 160px;
position: absolute;
right: 30px;
top: 30px;
background: #DEFEF3;
padding: 20px;
display: none;
}
input[type="reset"]{
float: right;
}
</style>
<script type="text/javascript">
window.onload = function ()
{
var oform1 = document.getElementById('form1'),
oform2 = document.getElementById('form2');
oshowbox1 = document.getElementById('showbox1');
oshowbox2 = document.getElementById('showbox2'); function getchecked(form,name)
{
arr = [];
for(var i = 0; i < form[name].length; i++ )
{
if(form[name][i].checked == true)
{
arr.push(form[name][i].value)
}
}
if(form[name][0].type == 'radio')
{
return arr[0];
}
if(form[name][0].type == 'checkbox')
{
return arr;
}
}; for(var i = 0; i < oform1.income.length; i++ )
{
oform1.income[i].onclick = function ()
{
showbox1.style.display = 'block';
showbox1.innerHTML = '您现在得收入是:' + getchecked(oform1,'income');
}
} for(var i = 0; i < oform2.character.length; i++ )
{
oform2.character[i].onclick =function ()
{
showbox2.style.display = 'block';
showbox2.innerHTML = '您现在得收入是:' + getchecked(oform2,'character').join(' ');
}
}
oform1.onreset = function ()
{
var re = confirm ('你确定要重置吗?');
if(re)
{
showbox1.style.display = 'none';
return true;
}
else
{
return false;
}
} oform2.onreset = function ()
{
var re = confirm('你确定要重置吗?');
if(re)
{
showbox2.style.display = 'none';
return true;
}
else
{
return false;
}
} }
</script>
</head> <body>
<form id="form1">
<label>您的月收入水平是:</label>
<input type="radio" name="income" value="1000元以下">1000元以下<br/>
<input type="radio" name="income" value="1000~3000元">1000~3000元<br/>
<input type="radio" name="income" value="3000~5000元">3000~5000元<br/>
<input type="radio" name="income" value="5000~10000元">5000~10000元<br/>
<input type="radio" name="income" value="10000~20000元">10000~20000元<br/>
<input type="radio" name="income" value="20000元以上">20000元以上
<div id="showbox1"></div>
<input type="reset" name="reset" value="重置">
</form>
<form id="form2">
<label>您的性格是:</label>
<input type="checkbox" name="character" value="开朗">开朗
<br>
<input type="checkbox" name="character" value="随性">随性
<br>
<input type="checkbox" name="character" value="阴郁">阴郁
<br>
<input type="checkbox" name="character" value="果断">果断
<br>
<input type="checkbox" name="character" value="冷静">冷静
<br>
<input type="checkbox" name="character" value="奔放">奔放
<br>
<input type="checkbox" name="character" value="内敛">内敛
<br>
<input type="checkbox" name="character" value="稳重">稳重
<div id="showbox2"></div>
<input type="reset" name="reset" value="重置">
</form>
</body>
</html>

最新文章

  1. 10 Minutes to pandas
  2. Scala Macros - 元编程 Metaprogramming with Def Macros
  3. Oracle 11g 编译使用BBED
  4. nodejs事件模块
  5. 剑指Offer 二维数组中的查找
  6. main函数中argc和argv含义
  7. UVa 442 矩阵链乘(栈)
  8. 【ArcEngine入门与提高】Element(元素)、Annotation(注记)旋转
  9. FIREDAC直连ORACLE数据库
  10. jquery 设置style:display 其实很方便的
  11. UML-用例
  12. Stack(栈)
  13. python的解释器spython介绍
  14. smartFloat
  15. 【转载】常用 Java 静态代码分析工具的分析与比较
  16. CentOS7.3环境下源码安装httpd
  17. angular 项目 error TS2451: Cannot redeclare block-scoped variable &#39;ngDevMode&#39;
  18. Java Calender 类详解
  19. Spark:求出分组内的TopN
  20. [LintCode] Invert Binary Tree 翻转二叉树

热门文章

  1. [CCF2015.09]题解
  2. remove duplicates in Postgres(sql去重)
  3. combobox远程加载数据的总结和Json数据的小结
  4. js兼容多浏览器的关闭当前页面
  5. Qt之透明提示框
  6. 最小生成树之Kruskal
  7. Nginx安全配置
  8. Android命令行播放MP3音乐
  9. jquery 获取和设置 select下拉框的值(转手册)
  10. android中handler用法总结