fc7e1a2206ec09190b5adc707ecf31c168538400.svn-base 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
  2. <%
  3. String path = request.getContextPath();
  4. %>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  9. <title>单选框</title>
  10. <!--框架必需start-->
  11. <script type="text/javascript" src="<%=path%>/libs/js/jquery.js"></script>
  12. <script type="text/javascript" src="<%=path%>/libs/js/language/cn.js"></script>
  13. <script type="text/javascript" src="<%=path%>/libs/js/framework.js"></script>
  14. <link href="<%=path%>/libs/css/import_basic.css" rel="stylesheet" type="text/css"/>
  15. <link rel="stylesheet" type="text/css" id="skin" prePath="<%=path%>/"/>
  16. <link rel="stylesheet" type="text/css" id="customSkin"/>
  17. <!--框架必需end-->
  18. </head>
  19. <body>
  20. <div class="box1" panelWidth="800">
  21. <fieldset>
  22. <legend>1、点击文字进行选中(推荐做法)</legend>
  23. 性别:<input type="radio" id="male-1" name="sex-1" value="男" /><label for="male-1" class="hand">男(Male)</label>
  24. <input type="radio" id="female-1" name="sex-1" value="女" /><label for="female-1" class="hand">女(Female)</label>
  25. </fieldset>
  26. <div class="height_15"></div>
  27. <fieldset>
  28. <legend>2、设置初始值</legend>
  29. 年龄:<input type="radio" id="lt25-2" name="age-2" value="小于25" /><label for="lt25-2" class="hand">小于25</label>
  30. <input type="radio" id="gt25-2" name="age-2" value="大于等于25" checked="checked"/><label for="gt25-2" class="hand">大于等于25</label>
  31. </fieldset>
  32. <div class="height_15"></div>
  33. <fieldset>
  34. <legend>3、动态选中某项</legend>
  35. 性别:<input type="radio" id="male-3" name="sex-3" value="男" /><label for="male-3" class="hand">男(Male)</label>
  36. <input type="radio" id="female-3" name="sex-3" value="女" /><label for="female-3" class="hand">女(Female)</label>
  37. <input type="button" value="我是女生" onclick="changeItem()"/>
  38. </fieldset>
  39. <div class="height_15"></div>
  40. <fieldset>
  41. <legend>4、禁用/启用</legend>
  42. 年龄:<input type="radio" id="lt25-4" name="age-4" value="小于25" disabled="disabled"/><label for="lt25-4" class="hand">小于25</label>
  43. <input type="radio" id="gt25-4" name="age-4" value="大于等于25" checked="checked" disabled="disabled"/><label for="gt25-4" class="hand">大于等于25</label>
  44. <br/>
  45. <input type="button" value="启用" onclick="enableSelect()" style="width:105px;"/>
  46. <input type="button" value="禁用" onclick="disableSelect()" style="width:105px;"/>
  47. </fieldset>
  48. <div class="height_15"></div>
  49. <fieldset>
  50. <legend>5、动态生成单选项</legend>
  51. <input type="button" value="点击生成单选项" id="testBtn"/>
  52. </fieldset>
  53. <div class="height_15"></div>
  54. <fieldset>
  55. <legend>6、获取选中项</legend>
  56. 性别:<input type="radio" id="male-6" name="sex-6" value="男" checked="checked"/><label for="male-6" class="hand">男(Male)</label>
  57. <input type="radio" id="female-6" name="sex-6" value="女" /><label for="female-6" class="hand">女(Female)</label>
  58. <input type="button" value="获取选中项的值" onclick="getRadioValue()"/>
  59. </fieldset>
  60. <div class="height_15"></div>
  61. <fieldset>
  62. <legend>7、自定义样式(部分皮肤有效)</legend>
  63. 自定义样式只在支持CSS3的浏览器中生效,例如IE9以上、firefox、chrome,低版本浏览器会显示原生的radio样式。
  64. <div class="checkboxRender">
  65. 性别:<input type="radio" id="male-7" name="sex-7" value="男" /><label for="male-7" class="hand">男(Male)</label>
  66. <input type="radio" id="female-7" name="sex-7" value="女" /><label for="female-7" class="hand">女(Female)</label>
  67. </div>
  68. </fieldset>
  69. </div>
  70. <script type="text/javascript">
  71. //改变Radio的值
  72. function changeItem(){
  73. $("input:radio[name=sex-3]").eq(1).attr("checked",true);
  74. }
  75. //生成单选项
  76. var counter = 10;
  77. $(function(){
  78. $("#testBtn").click(function(){
  79. var radioStr = "<input type='radio' id='love-" + counter + "' name='hobby' value=" + counter + "/><label class='hand' for='love-" + counter + "'>爱好" + counter + "</label>";
  80. var $input=$(radioStr);
  81. $(this).after($input);
  82. counter++;
  83. })
  84. })
  85. //获取选中项的值
  86. function getRadioValue(){
  87. top.Dialog.alert($("input:radio[name=sex-6]").filter("[checked]").val());
  88. }
  89. //设为不可用
  90. function disableSelect(){
  91. $("#lt25-4").attr("disabled",true);
  92. $("#gt25-4").attr("disabled",true);
  93. }
  94. //设为可用
  95. function enableSelect(){
  96. $("#lt25-4").attr("disabled",false);
  97. $("#gt25-4").attr("disabled",false);
  98. }
  99. </script>
  100. </body>
  101. </html>