首页 > 其他 > 详细

三联动11

时间:2014-08-05 13:31:39      阅读:240      评论:0      收藏:0      [点我收藏+]
数据库crm_province(AUTOid,TypeName)、crm_city(ID,province_id,city_title)、crm_area(ID,province_id,city_id,area_title)

注:MYSQL数据库连接正确(即:include_once("../inc/conn.php")文件和路径均完全正确)

<?php include_once("../inc/conn.php");?>
<script language="JavaScript">
<!--
var subval2 = new Array();
<?php

$sqlClass2=mysql_query("select * from crm_city order by ID asc");
$rsClass2=mysql_fetch_array($sqlClass2);
$count2=0;
if($rsClass2!=false)
{
do
{
?>
subval2[<?php echo $count2;?>] = new Array(‘<?php echo $rsClass2[province_id];?>‘,‘<?php echo $rsClass2[ID];?>‘,‘<?php echo $rsClass2[city_title];?>‘);
<?php
$count2=$count2+1;
}
while($rsClass2=mysql_fetch_array($sqlClass2));
}
?>
onecount2=<?php echo $count2;?>;

var subval3 = new Array();
<?php
$sqlClass3=mysql_query("select * from crm_area order by ID asc");
$rsClass3=mysql_fetch_array($sqlClass3);
$count3=0;
if($rsClass3!=false)
{
do
{
?>
subval3[<?php echo $count3;?>] = new Array(‘<?php echo $rsClass3[city_id];?>‘,‘<?php echo $rsClass3[ID];?>‘,‘<?php echo $rsClass3[area_title];?>‘);
<?php
$count3=$count3+1;
}
while($rsClass3=mysql_fetch_array($sqlClass3));
}
?>
onecount3=<?php echo $count3;?>; 

function changeselect1(locationid1)
{
    document.form1.s2.length = 0;
    document.form1.s2.options[0]=new Option(‘==所属市区==‘,‘‘);
    document.form1.s3.length = 0;
    document.form1.s3.options[0]=new Option(‘==所属区县==‘,‘‘);
    for (i=0;i<onecount2;i++)
    {
        if (subval2[i][0]==locationid1)
        {document.form1.s2.options[document.form1.s2.length]=new Option(subval2[i][2],subval2[i][1]);}
    }
}

function changeselect2(locationid2)
{
    document.form1.s3.length = 0;
    document.form1.s3.options[0] = new Option(‘==所属区县==‘,‘‘);
    for (i=0;i<onecount3;i++)
    {
        if (subval3[i][0]==locationid2)
        {document.form1.s3.options[document.form1.s3.length]=new Option(subval3[i][2],subval3[i][1]);}
    }
}
//-->
</script>

<table width="100%"  border="0" cellspacing="0" cellpadding="0">
<form name="form1" method="POST" action="a.php">
  <tr>
    <td width="150">
<select name="s1" onChange="changeselect1(this.value)">
<option>==所属省份==</option>
<?php
$sqlClass1=mysql_query("select * from crm_province order by autoID asc");
$rsClass1=mysql_fetch_array($sqlClass1);
$count1=0;
if($rsClass1!=false)
{
do
{
?>
<option value="<?php echo $rsClass1[autoID];?>"><?php echo $rsClass1[TypeName];?></option>
<?php
$count1++;
}
while($rsClass1=mysql_fetch_array($sqlClass1));
}
?>
</select><font color="#FF0000">*</font></td>
    <td width="150"><select name="s2"  onChange="changeselect2(this.value)"> 
<option>==所属市区==</option>
</select><font color="#FF0000">*</font></td>
    <td><select name="s3"> 
<option>==所属区县==</option>
</select><font color="#FF0000">*</font></td>
  </tr>
  </form>
</table>

三联动11,布布扣,bubuko.com

三联动11

原文:http://www.cnblogs.com/qiuyang1/p/3891870.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!