ASP

本类阅读TOP10

·asp常用数据库连接方法和技巧
·无组件生成BMP验证码
·一些常用的辅助代码 (网络收藏)
·JavaScript实现的数据表格:冻结列、调整列宽和客户端排序
·VisualStudio.NET_2003及其 MSDN 下载地址
·ASP模拟MVC模式编程
·图片以二进制流输出到网页
·MD5加密算法 ASP版
·ASP.NET编程中的十大技巧
·改进 ASP 的字符串处理性能

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
用php实现真正的----连动下拉列表

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

 

/***************************
* author: 大龄青年
* email : [email protected]
* from:http://blog.csdn.net/hahawen
***************************/下面的两个文件copy到同一个文件下,通过web路径访问index.html看看吧,这个是通过iframe来实现的连动更新,list.php目前的内容比较简单,你看通过list.php来进行数据库查询,然后显示出查询的结果列表。

index.html
<body>
<form name="myfrm">
<select name="mlist" onchange="changes();">
<option value="0">请选择...</option>
<option value="北京">北京</option>
<option value="通化">通化</option>
</select>&nbsp;
<select name="slist">
</select>
<iframe id="frame" src="list.php?city=" style="display:none;"></iframe>
<script language="javascript">
function changes(){
frame.location.href = "list.php?city=" + document.myfrm.mlist.value;
}
</script>
</form>
</body>


list.php

<?php
$data = array("北京"=>array("小强","旺财","小强他爹"),
"通化"=>array("小温","小宋","他们儿子"),);

$city = $_GET["city"];

$result = $data[$city];

$str = "<script language=\"javascript\">list = parent.document.myfrm.slist;list.length = 0;";

if($result==null)
$str .= "tmp = new Option(\"......\", \"\");list.options[0] = tmp;";
else
foreach($result as $i => $value)
$str .= "tmp = new Option(\"\", \"\");list.options[$i] = tmp;";
$str .= "</script>";

echo $str;
?>




相关文章

相关软件