Destoon7.0地区默认显示两个下垃框的办法

   日期:2019-03-09     浏览:29    评论:0    
核心提示:destoon的地区选择,默认只显示一个下拉,很不友好,所以改了下,让他默认显示两个下拉框效果如下打开include/post.func.php 找到function get_area_select($title = '', $areaid = 0, $extend = '

destoon的地区选择,默认只显示一个下拉,很不友好,所以改了下,让他默认显示两个下拉框

效果如下



打开include/post.func.php 找到 

function get_area_select($title = '', $areaid = 0, $extend = '', $deep = 0, $id = 1) {
global $db;
$parents = array();
if($areaid) {
$r = $db->get_one("SELECT child,arrparentid FROM {$db->pre}area WHERe areaid=$areaid");
$parents = explode(',', $r['arrparentid']);
if($r['child']){
                    $parents[] = $areaid;
                }
} else {
$parents[] = 0;

}
$select = '';
foreach($parents as $k=>$v) {
if($deep && $deep <= $k) break;
$v = intval($v);
$select .= '<select"load_area(this.value, '.$id.');" '.$extend.'>';
if($title) $select .= '<option value="'.$v.'">'.$title.'</option>';
$result = $db->query("SELECT areaid,areaname FROM {$db->pre}area WHERe parentid=$v ORDER BY listorder,areaid ASC");
while($a = $db->fetch_array($result)) {
$selectid = isset($parents[$k+1]) ? $parents[$k+1] : $areaid;
$selected = $a['areaid'] == $selectid ? ' selected' : '';
$select .= '<option value="'.$a['areaid'].'"'.$selected.'>'.$a['areaname'].'</option>';
}
$select .= '</select> ';
}
       
return $select;
}


修改成下面的代码

function get_area_select($title = '', $areaid = 0, $extend = '', $deep = 0, $id = 1) {
global $db;
$parents = array();
        $i = 0;
if($areaid) {
$r = $db->get_one("SELECT child,arrparentid FROM {$db->pre}area WHERe areaid=$areaid");
$parents = explode(',', $r['arrparentid']);
if($r['child']){
                    $parents[] = $areaid;
                }else{
                    $i = 1;
                }
} else {
$parents[] = 0;
                $i = 1;
}
$select = '';
foreach($parents as $k=>$v) {
if($deep && $deep <= $k) break;
$v = intval($v);
$select .= '<select"load_area(this.value, '.$id.');" '.$extend.'>';
if($title) $select .= '<option value="'.$v.'">'.$title.'</option>';
$result = $db->query("SELECT areaid,areaname FROM {$db->pre}area WHERe parentid=$v ORDER BY listorder,areaid ASC");
while($a = $db->fetch_array($result)) {
$selectid = isset($parents[$k+1]) ? $parents[$k+1] : $areaid;
$selected = $a['areaid'] == $selectid ? ' selected' : '';
$select .= '<option value="'.$a['areaid'].'"'.$selected.'>'.$a['areaname'].'</option>';
}
$select .= '</select> ';
}
        if($i){
           $select .= '<select '.$extend.'>';
           $select .= '<option value=" "'.$selected.'>所在城市</option>';
           $select .= '</select> ';
        }
return $select;
}


大功告成


 
打赏
0相关评论

电话咨询

咨询电话:
0775-7279380(座机)
18176930112 13878897862

微信咨询

千人QQ交流群

在线客服

售后服务

回到顶部