add.php 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <div class="main-content-inner">
  2. <div class="breadcrumbs" id="breadcrumbs">
  3. <ul class="breadcrumb">
  4. <li>
  5. <i class="ace-icon fa fa-home home-icon"></i>
  6. <a>首页</a>
  7. </li>
  8. <li>
  9. <a>学生管理</a>
  10. </li>
  11. <li class="active">添加学生</li>
  12. </ul>
  13. </div>
  14. <div class="page-content">
  15. <div class="row">
  16. <div class="col-xs-12">
  17. <!-- PAGE CONTENT BEGINS -->
  18. <form class="form-horizontal" action="<?php echo $this->createUrl('userinfo/add');?>" method="post" id="userInfoSubmit">
  19. <div class="form-group">
  20. <label class="control-label col-xs-12 col-sm-3 no-padding-right">选择年级:</label>
  21. <div class="col-xs-12 col-sm-9">
  22. <div class="clearfix">
  23. <select class="input-medium" onchange="changeYears(this.value);" name="years_id" id="years_id">
  24. <option value="">请选择年级</option>
  25. <?php if(!empty($yearsInfo)):foreach($yearsInfo as $loop):?>
  26. <option value="<?php echo $loop->years_id;?>"><?php echo $loop->years_name;?></option>
  27. <?php endforeach;endif;?>
  28. </select>
  29. </div>
  30. </div>
  31. <div class="col-xs-12 col-sm-9" id="classDiv" style="display:none;">
  32. <div class="clearfix">
  33. <select class="input-medium" id="class_id" name="class_id">
  34. </select>
  35. </div>
  36. </div>
  37. </div>
  38. <div class="form-group">
  39. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录账号:</label>
  40. <div class="col-sm-9">
  41. <input type="text" id="school" name="username" class="col-xs-10 col-sm-3" />
  42. </div>
  43. </div>
  44. <div class="form-group">
  45. <label class="control-label col-xs-12 col-sm-3 no-padding-right">登录密码:</label>
  46. <div class="col-sm-9">
  47. <input type="password" id="password" name="password" class="col-xs-10 col-sm-3" />
  48. </div>
  49. </div>
  50. <div class="form-group">
  51. <label class="control-label col-xs-12 col-sm-3 no-padding-right">确认密码:</label>
  52. <div class="col-sm-9">
  53. <input type="password" id="password2" name="password2" class="col-xs-10 col-sm-3" />
  54. </div>
  55. </div>
  56. <div class="hr hr-16 hr-dotted"></div>
  57. <div class="form-group">
  58. <label class="control-label col-xs-12 col-sm-3 no-padding-right">真实姓名:</label>
  59. <div class="col-xs-12 col-sm-9">
  60. <input type="text" name="realname" class="col-xs-10 col-sm-3" />
  61. </div>
  62. </div>
  63. <div class="form-group">
  64. <label class="control-label col-xs-12 col-sm-3 no-padding-right">学号:</label>
  65. <div class="col-xs-12 col-sm-9">
  66. <input type="text" name="userno" class="col-xs-10 col-sm-3" />
  67. </div>
  68. </div>
  69. <div class="form-group">
  70. <label class="control-label col-xs-12 col-sm-3 no-padding-right">性别:</label>
  71. <div class="col-xs-12 col-sm-9">
  72. <div>
  73. <label class="line-height-1 blue">
  74. <input name="sex" value="1" type="radio" class="ace sex" checked="checked" />
  75. <span class="lbl"> 男</span>
  76. </label>
  77. </div>
  78. <div>
  79. <label class="line-height-1 blue">
  80. <input name="sex" value="2" type="radio" class="ace sex" />
  81. <span class="lbl"> 女</span>
  82. </label>
  83. </div>
  84. </div>
  85. </div>
  86. <div class="clearfix form-actions">
  87. <div class="col-md-offset-3 col-md-9">
  88. <button class="btn btn-info" type="submit" id="schoolSubmit">
  89. <i class="ace-icon fa fa-check bigger-110"></i>
  90. 提交
  91. </button>
  92. &nbsp; &nbsp; &nbsp;
  93. <button class="btn" type="reset">
  94. <i class="ace-icon fa fa-undo bigger-110"></i>
  95. 重填
  96. </button>
  97. </div>
  98. </div>
  99. </form>
  100. <!-- PAGE CONTENT ENDS -->
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. <script src="/js/jquery.validate.min.js"></script>
  106. <script type="text/javascript">
  107. jQuery(function($) {
  108. $('#userInfoSubmit').validate({
  109. //debug:true,// 表单不会提交
  110. //errorElement: 'font', // 错误信息div
  111. errorClass: 'errorMessage', //错误样式
  112. ignore: "", //忽略提交字段
  113. rules: {
  114. years_id: {
  115. required: true,
  116. },
  117. class_id: {
  118. required: true,
  119. },
  120. username: {
  121. required: true,
  122. },
  123. password: {
  124. required: true,
  125. minlength: 6
  126. },
  127. password2: {
  128. required: true,
  129. minlength: 6,
  130. equalTo: "#password"
  131. },
  132. sex: {
  133. required: true,
  134. },
  135. realname: {
  136. required: true,
  137. },
  138. userno: {
  139. required: true,
  140. }
  141. },
  142. messages: {
  143. years_id: {
  144. required: "请选择年级!",
  145. },
  146. class_id: {
  147. required: "请选择班级!",
  148. },
  149. username: {
  150. required: "请填写登录账号!",
  151. },
  152. password: {
  153. required: "请填写登录密码!",
  154. minlength: "密码不能少于6位字符!"
  155. },
  156. password2: {
  157. required: "请填写确认密码!",
  158. minlength: "密码不能少于6位字符!",
  159. equalTo: "两次密码输入不一致!"
  160. },
  161. realname: {
  162. required: "请填写真实姓名!",
  163. },
  164. sex: {
  165. required: "请选择性别!",
  166. },
  167. userno: {
  168. required: "请填写学号!",
  169. }
  170. },
  171. errorPlacement: function (error, element) { // 指定错误信息显示位置
  172. if(element.is('input[type=radio]')) {
  173. var controls = element.closest('div[class*="col-"]');
  174. if(controls.find(':checkbox,:radio').length > 1) controls.append(error);
  175. else error.insertAfter(element.nextAll('.lbl:eq(0)').eq(0));
  176. }else{
  177. error.insertAfter(element.after());
  178. }
  179. },
  180. })
  181. });
  182. // ajax获取班级
  183. function changeYears(num) {
  184. if (!num) return;
  185. $.post("<?php echo $this->createUrl('classes/ajaxclass');?>",{yid:num},function(data){
  186. var p = eval("("+data+")");
  187. if (p.flag) {
  188. $("#classDiv").show();
  189. var html;
  190. var cityObj = $("#class_id");
  191. cityObj.empty();
  192. if (p.classList.length > 0){
  193. html = "<option value=''>请选择班级</option>";
  194. $.each(p.classList,function(i,n){
  195. html += "<option value='"+n.class_id+"'>" + n.class_name + "</option>";
  196. });
  197. } else {
  198. html = "<option value=''>暂无班级</option>";
  199. }
  200. cityObj.append(html);
  201. } else {
  202. alert("获取数据失败!");
  203. }
  204. });
  205. }
  206. </script>