Home > Backend Development > PHP Tutorial > 用php实现真正的连动下拉列表_PHP

用php实现真正的连动下拉列表_PHP

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-06-01 12:32:04
Original
1132 people have browsed it

下面的两个文件copy到同一个文件下,通过web路径访问index.html看看吧,这个是通过iframe来实现的连动更新,list.php目前的内容比较简单,你看通过list.php来进行数据库查询,然后显示出查询的结果列表。

index.html



 






list.php

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

$city = $_GET["city"];

$result = $data[$city];

$str = "

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

echo $str;
?>

Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template