php--spry框架制作级联下拉菜单

t78.php

<?php
header('Content-Type:text/xml');
?>

<root>
    <father id="1">
        <name>zhang san</name>
    </father>
    <father id="2">
        <name>li si</name>
    </father>
    <father id="3">
        <name>wang wu</name>
    </father>
</root>



t79.php

<?php
header('Content-Type:text/xml');
?>

<root>
    <?php if($_REQUEST['father_id'] == 1):?>
    <child>
        <name>zhang san xiao</name>
    </child>
    <child>
        <name>zhang san da</name>
    </child>
    <?php elseif($_REQUEST['father_id'] == 2):?>
    <child>
        <name>li si xiao</name>
    </child>
    <child>
        <name>li si da</name>
    </child>
    <child>
        <name>li si ping</name>
    </child>
    <child>
        <name>li si lan</name>
    </child>
    <?php elseif($_REQUEST['father_id'] == 3):?>
    <child>
        <name>wang wu xiao</name>
    </child>
    <child>
        <name>wang wu da</name>
    </child>
    <?php endif;?>
</root>

t80.php

<!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" xmlns:spry="http://ns.adobe.com/spry">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title>shi yong spry zhi zuo ji lian xia la cai dan</title>
    //引入spry框架
    <script type="text/javascript" src="Spry_1_6/includes/xpath.js"></script>
    //引入数据集
    <script type="text/javascript" src="Spry_1_6/includes/SpryData.js"></script>
    //脚本
    <script type="text/javascript">
        var dataset_father = new Spry.Data.XMLDataSet("t78.php","root/father");
        var dataset_child = new Spry.Data.XMLDataSet("t79.php","root/child");
        //加载child
        function re_load()
        {
            var father_id = document.getElementById('father').value;
            dataset_child.setURL("t79.php?father_id="+father_id);
            dataset_child.loadData();
            return false;
        }
    </script>
    <style type="text/css">
        body,td,th,select
        {
            font-family: Arial,Helvetica,sans-serif;
            font-size: 14px;
        }
    </style>
</head>
<body>
    <span>ji lian xia la cai dan</span>
    <hr>
    //father的数据区域
    <span spry:region="dataset_father">
        //状态
        <span spry:state="loading">shu ju jia zai zhong...</span>
        <span spry:state="failed">shu ju jia zai cuo wu!</span>
        <span spry:state="ready">
            father:
            <select name="father" id="father" onchange="re_load()">
                <option value="" selected="selected">qing xuan ze</option>
                //绑定数据
                <option value="{@id}" spry:repeat="dataset_father">{name}</option>
            </select>
        </span>
    </span>
    //child的数据区域
    <span spry:region="dataset_child">
        //状态
        <span spry:state="loading">shu ju jia zai zhong...</span>
        <span spry:state="failed">shu ju jia zai cuo wu!</span>
        <span spry:state="ready">
            child:
            <select name="child" id="child">
                <option value="" selected="selected">qing xuan ze</option>
                //绑定数据
                <option value="{name}" spry:repeat="dataset_child">{name}</option>
            </select>
        </span>
    </span>
</body>
</html>

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

虾米大王

有你的支持,我会更有动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值