日期:2014-05-16  浏览次数:20455 次

JS代码使地区子类直接显示在地区父类下面
if (get[2]=='')
{
opthtm+='<div class="litit csel">地区:</div>';
opthtm+='<div class="littxt">';
opthtm+='<ul class="link_bk min">';
var len=QS_city_parent.length;
minlen=len>12?11:len;
for(var i=0;i<minlen;i++)
{
arr =QS_city_parent[i].split(",");
opthtm+='<li><a href="'+href+'" id="district-'+arr[0]+'" class="opt">'+arr[1]+'</a></li>';
}
if (len>12)
{
for(var i=minlen;i<len;i++)
{
arr =QS_city_parent[i].split(",");
opthtm+='<li class="hide"><a href="'+href+'" id="district-'+arr[0]+'" class="opt">'+arr[1]+'</a></li>';
}
opthtm+='<li class="more"><a href="'+href+'">更多</a></li>';
}
opthtm+='</ul>';
opthtm+='<div class="clear"></div>';
opthtm+='</div>';
opthtm+='<div class="clear"></div>';
}
else
{
var districtname='';
for(var i=0;i<QS_city_parent.length;i++)
{
arr =QS_city_parent[i].split(",");
if (arr[0]==get[2])districtname=arr[1];
}
opthtm+='<div class="litit csel">地区:</div>';
opthtm+='<div class="littxt">';
opthtm+='<ul class="link_bk">';
if (districtname)
{
sdistrictstr=QS_city[get[2]];
var b="";
if (sdistrictstr)
{
b="<span>▼</span>";
}
opthtm+='<li><span id="district-'+get[2]+'">'+districtname+'</span>'+b+'</li>';
}
else
{
alert('参数错误');
}
opthtm+='</ul>';
opthtm+='<div class="clear"></div>';
opthtm+='</div>'; 
opthtm+='<div class="clear"></div>';
sdistrictstr=QS_city[get[2]];
if (sdistrictstr)//如果有子类
{
if (get[3]=='')
{
arrsubclass=sdistrictstr.split("|");
var len=arrsubclass.length;
if (len>0)
{
opthtm+='<div class="litit csel">地区子类:</div>';
opthtm+='<div class="littxt">';
opthtm+='<ul class="link_bk">'; 
minlen=len>12?11:len;
for(var i=0;i<minlen;i++)
{
arr =arrsubclass[i].split(",");
opthtm+='<li><a href="'+href+'" id="sdistrict-'+arr[0]+'" class="opt">'+arr[1]+'</a></li>';
}
if (len>12)
{
for(var i=minlen;i<len;i++)
{
arr =arrsubclass[i].split(",");
opthtm+='<li class="hide"><a href="'+href+'" id="sdistrict-'+arr[0]+'" class="opt">'+arr[1]+'</a></li>';
}
opthtm+='<li class="more"><a href="'+href+'">更多</a></li>';
}
opthtm+='</ul>';
opthtm+='<div class="clear"></div>';
opthtm+='</div>'; 
opthtm+='<div class="clear"></div>';
}
}
else
{
arrsubclass=sdistrictstr.split("|");
for(var i=0;i<arrsubclass.length;i++)
{
arr =arrsubclass[i].split(",");
if (arr[0]==get[3])subclassname=arr[1];
}
if(subclassname)
{
opthtm+='<div class="litit csel">地区子类:</div>';
opthtm+='<div class="littxt">';
opthtm+='<ul class="link_bk">';
opthtm+='<li><span id="sdistrict-'+get[3]+'">'+subclassname+'</span></li>';
opthtm+='</ul>';
opthtm+='<div class="clear"></div>';