jquery与zend framework编写的联动选项效果

html部分:

<pre name="code" class="html"><!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" />
<link type="text/css" rel="stylesheet" href="/css/dmcx.css"/>
<link type="text/css" rel="stylesheet" href="/css/duoxuan1.css"/>
<script type="text/javascript" src="/js/jquery.js"></script>
<script type="text/javascript" src="/js/cxjl.js"></script>
<script type="text/javascript" src="/js/jquery_duoxuan1.js"></script>
<title>MYTITLE</title>
</head>
<body bgcolor="#fff">
    <div id="div">
       <div align="center" id="div2" >                 
           <form id="form1" method="post" action="/Dyjsdp/dyjsdp">
              <select id="college">
          	       <option>---请选择学院---</option>
              </select>
              <select id="major">
			       <option>---请选择专业---</option>
		      </select>                         
              <input type="submit"  value="查询"/>
            </form>
       </div>
</body>
</html>

 

jquery部分:

<script type="text/javascript">
$(document).ready(function(){
	//联动下拉菜单
	$("#college").load("/dyjsdp/college");
	$("#college").change(function(){
		$("#major").load("/dyjsdp/major","college="+$(this).val());		
	});
	$("#major").change(function(){
	    $("#classes").load("/dyjsdp/class","major="+$(this).val());		
	});

});
</script>

zend framework部分:

    //学院联动
    public function collegeAction(){
        //header("Content-Type:text/html;charset=utf-8");
        header("Cache-Control:no-cache");
        
        $colleges=new College();
        $res=$colleges->fetchAll();
        echo "<option>--请选择学院--</option>";
        foreach ($res as $college){
            echo "<option>".$college['name']."</option>";
        }
        exit();
    }
    //专业联动
    public function majorAction(){
        //header("Content-Type:text/xml;charset=utf-8");
        header("Cache-Control:no-cache");
        $college=$this->getRequest()->getParam("college");
        //file_put_contents("G:/php/myenv/mylog.log",$college);
        $majors=new Major();
        $db=$majors->getAdapter();
        $sql=$db->quoteInto("select m.name from college c,major m where c.id=m.college_id and c.name=?", $college);
        $res=$db->query($sql)->fetchAll();

        echo "<option>---请选择专业---</option>";
        foreach ($res as $major){
            echo "<option>".$major['name']."</option>";
        }
        exit();
    }



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值