jquery_ajax_+php_级联列表.doc_第1页
jquery_ajax_+php_级联列表.doc_第2页
jquery_ajax_+php_级联列表.doc_第3页
jquery_ajax_+php_级联列表.doc_第4页
jquery_ajax_+php_级联列表.doc_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

主页面 jilian.php$(document).ready(function()$(#country).change(function()var cid = $(#country).val();$.post(province.php,id:cid,function(data)/alert(data);$(#province).html(data);$(#city).html(-请选择-);$(#county).html(-请选择-);$(#town).html(-请选择-);););$(#province).change(function()var pid = $(#province).val();$.post(city.php,id:pid,function(data)/alert(data);$(#city).html(data);$(#county).html(-请选择-);$(#town).html(-请选择-);););$(#city).change(function()var cid = $(#city).val();$.post(county.php,id:cid,function(data)/alert(data);$(#county).html(data);$(#town).html(-请选择-);););$(#county).change(function()var xid = $(#county).val();$.post(town.php,id:xid,function(data)/alert(data);$(#town).html(data);););); !- -国家 -请选择- option value= 省份 -请选择- 城市 -请选择- 县城 -请选择- 城镇 -请选择- !- -处理页面 province.php?php/* * Created on 2011-9-28 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ include_once(fun.php); $cid=$_POSTid; /$cid = 1; $sql = select * from Provinces where cid=.$cid.; $res = mysql_query($sql); $arr8 = array(); while($r = mysql_fetch_array($res) $arr8 = array($rpid,$rprovince); /print_r($arr8);$str = ;$str .= -请选择-;for($i=0;$icount($arr8);$i+)$str .=$arr8$i1;echo $str;?city.php?php/* * Created on 2011-9-28 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ include_once(fun.php); $pid=$_POSTid; /$cid = 1; $sql = select * from City where pid=.$pid.; $res = mysql_query($sql); $arr8 = array(); while($r = mysql_fetch_array($res) $arr8 = array($rcid,$rcity); /print_r($arr8);$str = ;$str .= -请选择-;for($i=0;$icount($arr8);$i+)$str .=$arr8$i1;echo $str;?county.php?php/* * Created on 2011-9-28 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ include_once(fun.php); $cid=$_POSTid; /$cid = 1; $sql = select * from County where cid=.$cid.; $res = mysql_query($sql); $arr8 = array(); while($r = mysql_fetch_array($res) $arr8 = array($rxid,$rcounty); /print_r($arr8);$str = ;$str .= -请选择-;for($i=0;$icount($arr8);$i+)$str .=$arr8$i1;echo $str;?town.php?php/* * Created on 2011-9-28 * * To change the template for this generated file go to * Window - Preferences - PHPeclipse - PHP - Code Templates */ include_once(fun.php); $xid=$_POSTid; /$cid = 1; $sql = select * from Town where xid=.$xid.; $res = mysql_query($sql); $arr8 = array(); while($r = mysql_fetch_array($res) $arr8 = array($rtid,$rtown); /print_r($arr8);$str = ;$str .= -请选择-;for($i=0;$icount($arr8);$i+)$str .=$arr8$i1;echo $str;?数据库连接fun.php数据库:数据库名COUNTRY/*Navicat MySQL Data TransferSource Server : 192.168.110.12_3306Source Server Version : 50152Source Host : 192.168.110.12:3306Source Database : COUNTRYTarget Server Type : MYSQLTarget Server Version : 50152File Encoding : 65001Date: 2011-09-29 15:38:27*/SET FOREIGN_KEY_CHECKS=0;- - Table structure for City- -DROP TABLE IF EXISTS City;CREATE TABLE City ( cid int(2) NOT NULL AUTO_INCREMENT, pid int(2) NOT NULL, city varchar(20) NOT NULL, PRIMARY KEY (cid) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;- - Records of City- -INSERT INTO City VALUES (1, 1, 石家庄);INSERT INTO City VALUES (2, 1, 衡水);INSERT INTO City VALUES (3, 1, 保定);INSERT INTO City VALUES (4, 2, 郑州);INSERT INTO City VALUES (5, 2, 洛阳);INSERT INTO City VALUES (6, 2, 驻马店);INSERT INTO City VALUES (7, 3, 苏州);INSERT INTO City VALUES (8, 3, 宿迁);INSERT INTO City VALUES (9, 3, 南京);INSERT INTO City VALUES (10, 4, 长沙);INSERT INTO City VALUES (11, 4, 衡阳);INSERT INTO City VALUES (12, 4, 张家界);INSERT INTO City VALUES (13, 5, 亚拉巴马州);INSERT INTO City VALUES (14, 5, 阿拉斯加州);INSERT INTO City VALUES (15, 5, 亚利桑那州);INSERT INTO City VALUES (16, 6, 阿肯色州);INSERT INTO City VALUES (17, 6, 加利福尼亚州);INSERT INTO City VALUES (18, 6, 科罗拉多州);INSERT INTO City VALUES (19, 7, 特拉华州);INSERT INTO City VALUES (20, 7, 佛罗里达州);INSERT INTO City VALUES (21, 8, 温哥华);INSERT INTO City VALUES (22, 9, 埃德蒙顿市);INSERT INTO City VALUES (23, 10, 瑞吉娜);- - Table structure for Country- -DROP TABLE IF EXISTS Country;CREATE TABLE Country ( cid int(2) NOT NULL AUTO_INCREMENT, country varchar(20) DEFAULT NULL, PRIMARY KEY (cid) ENGINE=InnoDB AUTO_INCREMENT=5 DEFAULT CHARSET=utf8;- - Records of Country- -INSERT INTO Country VALUES (1, 中国);INSERT INTO Country VALUES (2, 美国);INSERT INTO Country VALUES (3, 加拿大);- - Table structure for County- -DROP TABLE IF EXISTS County;CREATE TABLE County ( xid int(2) NOT NULL AUTO_INCREMENT, cid int(2) NOT NULL, county varchar(20) NOT NULL, PRIMARY KEY (xid) ENGINE=MyISAM AUTO_INCREMENT=24 DEFAULT CHARSET=utf8;- - Records of County- -INSERT INTO County VALUES (1, 1, 正定县);INSERT INTO County VALUES (2, 2, 景县);INSERT INTO County VALUES (3, 3, 保定的县);INSERT INTO County VALUES (4, 4, 郑州的县);INSERT INTO County VALUES (5, 5, 洛阳的县);INSERT INTO County VALUES (6, 6, 驻马店的县);INSERT INTO County VALUES (7, 7, 昆山);INSERT INTO County VALUES (8, 8, 宿迁的县);INSERT INTO County VALUES (9, 9, 南京的县);INSERT INTO County VALUES (10, 10, 长沙的县);INSERT INTO County VALUES (11, 11, 衡阳的县);INSERT INTO County VALUES (12, 12, 张家界的县);INSERT INTO County VALUES (13, 13, 亚拉巴马);INSERT INTO County VALUES (14, 14, 阿拉斯加);INSERT INTO County VALUES (15, 15, 亚利桑那);INSERT INTO County VALUES (16, 16, 阿肯色);INSERT INTO County VALUES (17, 17, 加利福尼亚);INSERT INTO County VALUES (18, 18, 科罗拉多);INSERT INTO County VALUES (19, 19, 特拉华);INSERT INTO County VALUES (20, 20, 佛罗里达的县);INSERT INTO County VALUES (21, 21, 温哥华的县);INSERT INTO County VALUES (22, 22, 埃德蒙顿);INSERT INTO County VALUES (23, 23, 瑞吉娜的县);- - Table structure for Provinces- -DROP TABLE IF EXISTS Provinces;CREATE TABLE Provinces ( pid int(2) NOT NULL AUTO_INCREMENT, cid int(2) NOT NULL, province varchar(20) NOT NULL, PRIMARY KEY (pid) ENGINE=MyISAM AUTO_INCREMENT=14 DEFAULT CHARSET=utf8;- - Records of Provinces- -INSERT INTO Provinces VALUES (1, 1, 河北);INSERT INTO Provinces VALUES (2, 1, 河南);INSERT INTO Provinces VALUES (3, 1, 江苏);INSERT INTO Provinces VALUES (4, 1, 湖南);INSERT INTO Provinces VALUES (5, 2, 新英格兰地区);INSERT INTO Provinces VALUES (6, 2, 中央地区);INSERT INTO Provinces VALUES (7, 2, 中大西洋地区);INSERT INTO Provinces VALUES (8, 3, 不列颠哥伦比亚省);INSERT INTO Provinces VALUES (9, 3, 阿尔伯塔省);INSERT INTO Provinces VALUES (10, 3, 萨斯喀彻温省);- - Table structure for Town- -DROP TABLE IF EXISTS Town;CREATE TABLE Town ( tid int(2) NOT NULL AUTO_INCREMENT, xid int(2) NOT NULL, town varchar(20) NOT NULL, PRIMARY KEY (tid) ENGINE=MyISAM AUTO_INCREMENT=26 DEFAULT CHARSET=utf8;- - Records of Town- -INSERT INTO Town VALUES (1, 1, 正定的镇);INSERT INTO Town VALUES (2, 2, 杜桥);INSERT INTO Town VALUES (3, 2, 龙华);INSERT INTO Town VALUES (4, 3, 保定的镇);INSERT INTO Town VALUES (5, 4, 郑州的镇);INSERT INTO Town VALUES (6, 5

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论