아 저는 개발자 체질이 아닌가봅니다...

업종 | 시/도 | 구/군/읍 | 상호명 AJAX 사용하면 4번에 쿼리 날려야해서

그냥 캐싱 처리해서 1번만 날리자 싶어서 만들다가 거진 3-5시간을 쌩 노가다했네요..


DB을 잘못짜놔싸서 헷갈리더군요 하..


그래도뭐!! 해결됬으니 마음은 뿌듯합니다. 하하 ㅋ


<style type="text/css">
.ReturnCITY { display:none; }
.ReturnAREA { display:none; }
.ReturnPARTNER { display:none; }
</style>

<?php
$ReturnTYPE = "<select class='ReturnTYPE'><option value=''>선택하세요</option>";
$ReturnCITY = "";
$ReturnAREA = "";
$ReturnPARTNER = "";

$SelectType = " select * from partnershiptype order by TypeOrder asc ";
$QueryType = sql_query($SelectType);
while($RowType = sql_fetch_array($QueryType)){
 
 $ReturnTYPE .= "<option value='".$RowType['TypeNumber']."'>".$RowType['TypeName'].'</option>';
 $ReturnCITY .= "<select class='ReturnCITY' id='ReturnCITY".$RowType['TypeNumber']."'><option value=''>선택하세요</option>";
 $SelectCity = " select * from partnershipcity where CityType = 1 and TypeNumber = ".$RowType['TypeNumber']." ";
 $QueryCity = sql_query($SelectCity);
 while($RowCity = sql_fetch_array($QueryCity)){
  
  $ReturnCITY .= "<option value='".$RowCity['CityNumber']."'>".$RowCity['CityCity'].'</option>';
  $ReturnAREA .= "<select class='ReturnAREA' id='ReturnAREA".$RowCity['CityNumber']."'><option value=''>선택하세요</option>";
  $RowArea = " select * from partnershipcity where CityType = 2 and CityCity = ".$RowCity['CityNumber']." order by CityOrder asc ";
  $QueryArea = sql_query($RowArea);
  while($RowArea = sql_fetch_array($QueryArea)){
   
   $ReturnAREA .= "<option value='".$RowArea['CityNumber']."'>".$RowArea['CityArea'].'</option>';
   $ReturnPARTNER .= "<select class='ReturnPARTNER' id='ReturnPARTNER".$RowArea['CityNumber']."'><option value=''>선택하세요</option>";
   $RowPartner = " select * from partnership where PartnerArea = ".$RowArea['CityNumber']." ";
   $QueryPartner = sql_query($RowPartner);
   while($RowPartner = sql_fetch_array($QueryPartner)){
    
    $ReturnPARTNER .= "<option value='".$RowPartner['PartnerNumber']."'>".$RowPartner['PartnerName'].'</option>';

   }
   $ReturnPARTNER .= "</select>";
  }
  $ReturnAREA .= "</select>";
 }
 $ReturnCITY .= "</select>";
}
$ReturnTYPE .= "</select>";

echo $ReturnTYPE;
echo ' ';
echo $ReturnCITY;
echo ' ';
echo $ReturnAREA;
echo ' ';
echo $ReturnPARTNER;
?>

<script type="text/javascript">
$(document).ready(function(){
 $('.ReturnTYPE').change(function(){
  $('.ReturnCITY').hide();
  $(".ReturnCITY option[value='']").attr("selected", "true");
  $('.ReturnAREA').hide();
  $(".ReturnAREA option[value='']").attr("selected", "true");
  $('.ReturnPARTNER').hide();
  $(".ReturnPARTNER option[value='']").attr("selected", "true");
  $("#ReturnCITY"+$('.ReturnTYPE option:selected').val()).fadeIn(300);
 });
  $('.ReturnCITY').change(function(){
  $('.ReturnAREA').hide();
  $(".ReturnAREA option[value='']").attr("selected", "true");
  $('.ReturnPARTNER').hide();
  $(".ReturnPARTNER option[value='']").attr("selected", "true");
  $("#ReturnAREA"+$(this).val()).fadeIn(300);
 });
 $('.ReturnAREA').change(function(){
  $('.ReturnPARTNER').hide();
  $(".ReturnPARTNER option[value='']").attr("selected", "true");
  $("#ReturnPARTNER"+$(this).val()).fadeIn(300);
 });
});
</script>



진정한 쌩노가다.. 제이쿼리는 어렵긴 디기 어렵네요;;

JS도 발로 배웠는데 PHP만 하다보니깐..

|

댓글 4개

축하드립니다. 수고 많으셨네요....^^
하아...이제 작업 1%된듯한 느낌을 뭘까요...
1달 넘게 작업해왔는데 하아..
개인 사이트 만드시나봐요?
네 ㅎ 사업추진중인 사이트 제작중 입니다.
2달잡고 생각했는데 어느덧 2달이 지나버렸네요..

퍼블리싱 디자인 개발 전부 직접하다보니 빡세긴 하네요..
댓글을 작성하시려면 로그인이 필요합니다.

자유게시판

+
제목 글쓴이 날짜 조회
12년 전 조회 1,113
12년 전 조회 1,353
12년 전 조회 1,832
12년 전 조회 1,267
12년 전 조회 1,214
12년 전 조회 3,740
12년 전 조회 1,212
12년 전 조회 2만
12년 전 조회 1,824
12년 전 조회 1,708
12년 전 조회 828
12년 전 조회 1,132
12년 전 조회 1,091
12년 전 조회 1,119
12년 전 조회 1,220
12년 전 조회 1,112
12년 전 조회 1,205
12년 전 조회 1,097
12년 전 조회 1,141
12년 전 조회 1,989
12년 전 조회 1,457
12년 전 조회 691
12년 전 조회 827
12년 전 조회 892
12년 전 조회 1,983
12년 전 조회 923
12년 전 조회 1,198
12년 전 조회 1,124
12년 전 조회 1,400
12년 전 조회 3,409