ThinkPHP实现联动

浏览:5962 发布日期:2013/05/03 分类:求助交流 关键字: 联动 案例
<?php 
/**  
*desc 卫生纪律考核 
 *author  陈晨 
 *date  2012/12/17
  */
 class HeadisAction extends Action {
     /*
      * 卫生纪律考核首页
      */
     public function ru_headis() {
         $this->display ();
     }
     /*
           * 个人卫生纪律考核
      */
     public function person() {
         //查询年级
         $grade = M ( 'sy_grade' );
         $check = M('sy_headis');
         $g_list = $grade->select ();
         //查出考核情况
        $ch_list = $check->select();
         //dump($g_list);
         $this->assign ( 'g_list', $g_list );
         $this->assign ( 'ch_list', $ch_list );
         $this->display ( 'ru_headis_person' );

     }
     /*
              * 根据年级查出班级
        */
     public function gra_class() {

         $class = M('sy_class');
         $c_list = $class->where('c_gId ='.$_GET['grade'])->select();
         //dump($c_list);
         $string = '<option value="">==请选择班级==</option>';
         for($i = 0; $i < count ( $c_list ); $i ++) {
             $string = $string. "<option value='" . $c_list [$i] ['c_Id'] . "'>" . $c_list [$i] ['c_Name'] . "</option>";
         }
         echo $string;

     }
    /*
     * 根据班级查出学生
   */
     public function cla_stu(){
         $student = M('stu_student');
         $s_list = $student->where('s_cId ='.$_GET['class'])->select();
         $string = '<option value="">==请选择学生==</option>';
         for($i = 0; $i < count ( $s_list ); $i ++) {
             $string = $string. "<option value='" . $s_list [$i] ['s_Id'] . "'>" . $s_list [$i] ['s_Name'] . "</option>";
         }
         echo $string;
     }
     /*
      * 根据考核查询分数
      */
     public function checkscore(){

       $score = M('sy_headis');
       $check = $score->where('h_Id ='.$_GET['score'])->find();
       echo $check['h_Score'];
     }

 }

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
 <HTML xmlns="http://www.w3.org/1999/xhtml"><HEAD id=Head1><TITLE>模板</TITLE>
 <META http-equiv=Content-Type content="text/html; charset=utf-8">
 <LINK href="__PUBLIC__/css/Style.css" type=text/css rel=stylesheet>
 <LINK href="__PUBLIC__/css/Manage.css" type=text/css rel=stylesheet>
 <SCRIPT language=javascript src="__PUBLIC__/js/FrameDiv.js"></SCRIPT>
 <SCRIPT language=javascript src="__PUBLIC__/js/Common.js"></SCRIPT>
 <SCRIPT language=javascript src="__PUBLIC__/js/jquery.js"></SCRIPT>
 <script language="Javascript" src="__PUBLIC__/js/My97DatePicker/calendar.js"></script>
 <script language="Javascript" src="__PUBLIC__/js/My97DatePicker/WdatePicker.js"></script>
 <META content="MSHTML 6.00.2900.3492" name=GENERATOR></HEAD>
 <BODY>
 <FORM id=form1 name=form1 method=post action="#">
 <SCRIPT type=text/javascript>
 //<![CDATA[
 var theForm = document.forms['form1'];
 if (!theForm) {
     theForm = document.form1;
 }
 function __doPostBack(eventTarget, eventArgument) {
     if (!theForm.onsubmit || (theForm.onsubmit() != false)) {
         theForm.__EVENTTARGET.value = eventTarget;
         theForm.__EVENTARGUMENT.value = eventArgument;
         theForm.submit();
     }
 }
 //]]>
 //联动班级
 $(document).ready(function(){

  $("#sClient").change(function(){
   $("#cClient").empty(); 
   $.get("__URL__/gra_class",{grade:$("#sClient").val()},function(data){
   //alert(data);
   $("#cClient").append(data);
   }) 
  })
 })
 //联动学生
 $(document).ready(function(){
  $("#cClient").change(function(){
  $("#stuClient").empty();
  $.get("__URL__/cla_stu",{class:$("#cClient").val()},function(sdata){
  //alert(sdata);
  $("#stuClient").append(sdata);
  })
  })
 })
 //联动加减分情况
 $(document).ready(function(){
 $(document).ready(function(){

  $("#score").empty();
  $.get("__URL__/checkscore",{score:$("#checkc").val()},function(cdata){
  //alert(cdata);
  $("#score").html(cdata);
  })
  })
 })

</SCRIPT>

 <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0 >
   <TBODY>
   <TR>
     <TD width=15><IMG src="__PUBLIC__/images/new_019.jpg" border=0></TD>
     <TD width="100%" background=__PUBLIC__/images/new_020.jpg height=20></TD>
     <TD width=15><IMG src="__PUBLIC__/images/new_021.jpg" 
   border=0></TD></TR></TBODY>
 </TABLE>
<TABLE  cellSpacing=0 cellPadding=0 width="98%" border=0 >
   <TBODY>
   <TR>
     <TD width=15 background=__PUBLIC__/images/new_022.jpg><IMG 
       src="__PUBLIC__/images/new_022.jpg" border=0> </TD>
     <TD vAlign=top width="100%" bgColor=#ffffff>
       <TABLE cellSpacing=0 cellPadding=5 width="100%" border=0>
         <TR>
           <TD class=manageHead>当前位置: 一日常规管理 > 卫生纪律管理 > 个人卫生纪律管理</TD></TR>
         <TR>
           <TD height=2></TD></TR></TABLE>
       <TABLE borderColor=#cccccc cellSpacing=0 cellPadding=0 width="100%" 
       align=center border=0 >
         <TBODY>
         <tr>
             <td align='center'>
                 <table>
                 <tr>
                 <td colspan='3' height='40'><span style="font-size:20px;font-weight:bold">个人卫生纪律考核</span></td>
                 </tr>
                 <tr>
                     <td>年级:</td>
                     <td height=30>
                     <SELECT id=sClient name=sClient style="width:130px">
                     <OPTION value="">==请选择年级==</OPTION>
                     <volist name="g_list" id="glist">
                     <OPTION value="{$glist.g_Id}">{$glist.g_Year}</OPTION> 
                     </volist>
                     </SELECT></td>
                     <td></td>
                 </tr>
                 </tr>
                     <td>班级:</td>
                     <td height=30><SELECT id=cClient name=sClient style="width:130px"> 

                     </SELECT></td>
                     <td></td>
                 </tr>
                 </tr>
                     <td>学生姓名:</td>
                     <td height=30><SELECT id=stuClient name=sClient style="width:130px">
                     </SELECT></td>
                     <td></td>
                 </tr>
                 <volist name="ch_list" id="check_list">
                 <tr>
                 <td>考核情况:</td>
                 <td height=30>
                 <SELECT id=checkc name=check style="width:130px">
                 <OPTION value="">==请选择==</OPTION>    
                     <OPTION value="{$check_list.h_Id}">{$check_list.h_Name}</OPTION> 

                     </SELECT>
                </td>
                 <td></td>
                 </tr>
                 </tr>
                 <td>加分:</td>
                 <td height=30>
                 <span id="score" style="border:#ABADB3 solid 1px;width:130px; height:18px;display:block"></span></td>
                 <td></td>
                 </tr>
                 </volist>
                 <tr>
                 <td>日期:</td>
                 <td height=30><input type="text" name="id" onClick="WdatePicker()"/></td>
                 <td></td>
                 </tr>
                 </tr>

                 <td height=30></td>
                 <td>
                 <input type="submit" name="id" value="添加"/>
                 <input type="reset" name="id" value="取消"/>
                 <input type="button" name="id" value="返回" onClick="javascript:history.go(-1)"/>
</td>
                 <td></td>
                 </tr>
                 </table>
             </td>
         </tr>
      </TBODY>
      </TABLE>
     </TD>
     <TD width=15 background=__PUBLIC__/images/new_023.jpg><IMG 
       src="__PUBLIC__/images/new_023.jpg" border=0> </TD></TR>

       </TBODY>
 </TABLE>
 <TABLE cellSpacing=0 cellPadding=0 width="98%" border=0>
   <TBODY>
   <TR>
     <TD width=15><IMG src="__PUBLIC__/images/new_024.jpg" border=0></TD>
     <TD align=middle width="100%" background=__PUBLIC__/images/new_025.jpg      height=15></TD>
     <TD width=15><IMG src="__PUBLIC__/images/new_026.jpg"    border=0></TD></TR></TBODY></TABLE>
 </FORM></BODY></HTML>
最佳答案
评论( 相关
后面还有条评论,点击查看>>