RSS
热门关键字:  下载  cms  模版  开源  dedecms
当前位置 :| 主页 > 站长学院 > PHP教程 >

来自若水修改---动态选择框

来源:Blog.ChinaUnix.net 作者:未知 时间:2006-09-14 Tag: 点击:
啦啦啦啦......

<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[i][0] == locationid)
        {
        document.FormData.City.options[document.FormData.City.length] = new Option(subcat[i][1], subcat[i][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'];
}   
?>


最新评论共有 0 位网友发表了评论
发表评论
评论内容:不能超过250字,需审核,请自觉遵守互联网相关政策法规。
用户名: 密码:
匿名?
注册