来自若水修改---动态选择框
时间:2007-02-17 来源:PHP爱好者
啦啦啦啦......<html>
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=??????">
<?
if( !( $link = mysql_connect('localhost','root','') ) ){
echo "Could not connect to local MySQL server.";
}if( !mysql_select_db('article'))
{
mysql_close( $link );
echo "Could not select database <b>ParserSample</b>.";
}$sql="select typeid,title from article_articles";
$query=mysql_query($sql,$link);
//while($rs=mysql_fetch_array($query)){
// echo $rs[0];}
?>
<script language = "Javascript">var onecount;
onecount = 0;
subcat = new Array();
<?
$count=0;
while($rs=mysql_fetch_array($query)){
?>
subcat[<?=$count;?>] = new Array("<?=$rs['typeid'];?>","<?=$rs['title'];?>");
<?
$count++;
}
?>
onecount=<?=$count?>;
function getCity(locationid)
{
document.FormData.City.length = 0; var locationid=locationid; var i;
document.FormData.City.options[0] = new Option('文章...','');
for (i=0;i <onecount; i++)
{
if (subcat[0] == locationid)
{
document.FormData.City.options[document.FormData.City.length] = new Option(subcat[1], subcat[0]);
}
}
}
</script>
</head>
<body>
<form name="FormData" method="post" action="">
分类:<select name="Province" onChange="getCity(document.FormData.Province.options[document.FormData.Province.selectedIndex].value);" size="1">
<option selected>请选择类别</option>
<option value="4">1</option>
<option value="2">2</option>
</select>
<select name="City" >
<option selected value="">==文章名==</option>
</select><INPUT TYPE="submit">
</form>
</body>
</html>
<?
if(!empty($_POST['City'])){
echo $_POST['City'];
}
?>
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
<head>
<title>List</title>
<meta http-equiv="Content-Type" content="text/html; charset=??????">
<?
if( !( $link = mysql_connect('localhost','root','') ) ){
echo "Could not connect to local MySQL server.";
}if( !mysql_select_db('article'))
{
mysql_close( $link );
echo "Could not select database <b>ParserSample</b>.";
}$sql="select typeid,title from article_articles";
$query=mysql_query($sql,$link);
//while($rs=mysql_fetch_array($query)){
// echo $rs[0];}
?>
<script language = "Javascript">var onecount;
onecount = 0;
subcat = new Array();
<?
$count=0;
while($rs=mysql_fetch_array($query)){
?>
subcat[<?=$count;?>] = new Array("<?=$rs['typeid'];?>","<?=$rs['title'];?>");
<?
$count++;
}
?>
onecount=<?=$count?>;
function getCity(locationid)
{
document.FormData.City.length = 0; var locationid=locationid; var i;
document.FormData.City.options[0] = new Option('文章...','');
for (i=0;i <onecount; i++)
{
if (subcat[0] == locationid)
{
document.FormData.City.options[document.FormData.City.length] = new Option(subcat[1], subcat[0]);
}
}
}
</script>
</head>
<body>
<form name="FormData" method="post" action="">
分类:<select name="Province" onChange="getCity(document.FormData.Province.options[document.FormData.Province.selectedIndex].value);" size="1">
<option selected>请选择类别</option>
<option value="4">1</option>
<option value="2">2</option>
</select>
<select name="City" >
<option selected value="">==文章名==</option>
</select><INPUT TYPE="submit">
</form>
</body>
</html>
<?
if(!empty($_POST['City'])){
echo $_POST['City'];
}
?>
php爱好 者站 http://www.phpfans.net php基础|php进阶|php模板.
相关阅读 更多 +