destoon 地区默认显示两个下垃框的办法

  2020-01-19    阅读:67
 destoon的地区选择,默认只显示一个下拉,很不友好,所以改了下,让他默认显示两个下拉框

效果如下

 

操作如下

打开include/post.func.php 找到 

 

  1. function get_area_select($title = '', $areaid = 0, $extend = '', $deep = 0, $id = 1) {
  2. global $db;
  3. $parents = array();
  4. if($areaid) {
  5. $r = $db->get_one("SELECt child,arrparentid FROM {$db->pre}area WHERe areaid=$areaid");
  6. $parents = explode(',', $r['arrparentid']);
  7. if($r['child']){
  8. $parents[] = $areaid;
  9. }
  10. } else {
  11. $parents[] = 0;
  12.  
  13. }
  14. $select = '';
  15. foreach($parents as $k=>$v) {
  16. if($deep && $deep <= $k) break;
  17. $v = intval($v);
  18. $select .= '<selectload_area(this.value, '.$id.');" '.$extend.'>';
  19. if($title) $select .= '<option value="'.$v.'">'.$title.'</option>';
  20. $result = $db->query("SELECT areaid,areaname FROM {$db->pre}area WHERe parentid=$v ORDER BY listorder,areaid ASC");
  21. while($a = $db->fetch_array($result)) {
  22. $selectid = isset($parents[$k+1]) ? $parents[$k+1] : $areaid;
  23. $selected = $a['areaid'] == $selectid ? ' selected' : '';
  24. $select .= '<option value="'.$a['areaid'].'"'.$selected.'>'.$a['areaname'].'</option>';
  25. }
  26. $select .= '</select> ';
  27. }
  28. return $select;
  29. }

将原代码修改成下面的代码

 

 

  1. function get_area_select($title = '', $areaid = 0, $extend = '', $deep = 0, $id = 1) {
  2. global $db;
  3. $parents = array();
  4. $i = 0;
  5. if($areaid) {
  6. $r = $db->get_one("SELECT child,arrparentid FROM {$db->pre}area WHERe areaid=$areaid");
  7. $parents = explode(',', $r['arrparentid']);
  8. if($r['child']){
  9. $parents[] = $areaid;
  10. }else{
  11. $i = 1;
  12. }
  13. } else {
  14. $parents[] = 0;
  15. $i = 1;
  16. }
  17. $select = '';
  18. foreach($parents as $k=>$v) {
  19. if($deep && $deep <= $k) break;
  20. $v = intval($v);
  21. $select .= '<selectload_area(this.value, '.$id.');" '.$extend.'>';
  22. if($title) $select .= '<option value="'.$v.'">'.$title.'</option>';
  23. $result = $db->query("SELECT areaid,areaname FROM {$db->pre}area WHERe parentid=$v ORDER BY listorder,areaid ASC");
  24. while($a = $db->fetch_array($result)) {
  25. $selectid = isset($parents[$k+1]) ? $parents[$k+1] : $areaid;
  26. $selected = $a['areaid'] == $selectid ? ' selected' : '';
  27. $select .= '<option value="'.$a['areaid'].'"'.$selected.'>'.$a['areaname'].'</option>';
  28. }
  29. $select .= '</select> ';
  30. }
  31. if($i){
  32. $select .= '<select '.$extend.'>';
  33. $select .= '<option value=" "'.$selected.'>所在城市</option>';
  34. $select .= '</select> ';
  35. }
  36. return $select;
  37. }

免责声明:
本站部份内容系网友自发上传与转载,不代表本网赞同其观点;
如涉及内容、版权等问题,请在30日内联系,我们将在第一时间删除内容!

相关Destoon技术

(c)2012-2023 www.qiyeyunshang.com All Rights Reserved.
慧一科技destoon模板   辽ICP备2021002520号-1
  QQ咨询

购买模板 售前咨询

  咨询QQ

3292628658
(早8:30-晚10:00)

  微信咨询

咨询微信
客服微信

  返回顶部