2013-08-17 1 views
0

연락처가 여러 개인 국가의 연락처 페이지가 있습니다. 따라서 위치를 필터링하려고 시도하고 도시 선택을하면 정보 창이있는 마커가 표시됩니다. 내 문제는 도시를 직접 선택하면 작동하지만 파일러 드롭 다운을 통과하면 작동하지 않습니다. 내가 뭘 잘못하고 있는지에 대해 조언 해주세요.Google지도 표시 마커가 작동하지 않습니다. 아약스를 사용하여 선택하십시오.

이 여기에 내가 onchange를 = 전화 드롭 다운 국가에 내 코드

내 링크 http://www.safarikidindia.com/demo_map.html

이다 'generatestate (이)'> &가 다운 상태 드롭에 도시를 생성합니다. 여기에 우리가 PHP 함수

 if($action=="showstate") 
{ 
$countryid = trim(filter_var($_REQUEST['countryid'], FILTER_SANITIZE_STRING)); 
$state = $safari->country_state_location($countryid); 

?> 
<select name="city" id="city" class="drpdown" onchange="geneeratecity(this);"> 
      <option value="">Select State</option> 
      <?php 

      for($i=0;$i<count($state);$i++) 
      { 

      $statename = $safari->get_singlestate($state[$i]['state']) 
      ?> 
       <option value="<?php echo $statename[0]['statesrno'];?>"><?php echo  $statename[0]['statename'];?></option> 
      <?php 
      } 
      ?> 


     </select> 
<?php 

} 

if($action=="geneeratecuty") 
{ 
$stateid = trim(filter_var($_REQUEST['stateid'], FILTER_SANITIZE_STRING)); 
$locations = $safari->country_city_location($stateid); 

?> 

     <select name="city" class="city" id="city"> 
      <option value="" selected>--- Select ---</option> 

         <?php 

     for($l=0;$l<count($locations);$l++) 
     { ?> 
     <option value="marker<?php echo $locations[$l]['srno'];?>"><?php echo $locations[$l]['city'];?></option> 





     <?php } ?> 
     </select> 




    <?php 

} 

    ?> 

답변

0

변경 청취자가 당신이 initialize를 호출 할 때 존재하는 # 도시 요소에 바인딩 다음 한 common_ajax에서 아약스 기능 코드

function generatestate(o) 
{ 

set_current_date_time() 
http.abort(); 
document.getElementById('locationstate').innerHTML = ''; 
document.getElementById('locationcity').innerHTML = ''; 
var url = "common_ajax.php?action=showstate&countryid="+o.options[o.selectedIndex].value; 
    //alert(url); 
    http.open("GET", url, true); 
    http.onreadystatechange=function() { 
    if(http.readyState == 4) { 
      //alert(http.responseText); 
      //var response = http.responseText; 

       document.getElementById('locationstate').innerHTML = http.responseText; 
     // alert(http.responseText); 

    } 
    } 
    http.send(null); 


} 



    function geneeratecity(o) 
{ 

set_current_date_time() 
http.abort(); 
document.getElementById('locationcity').innerHTML = ''; 

var url = "common_ajax.php?action=geneeratecuty&stateid="+o.options[o.selectedIndex].value; 
    //alert(url); 
    http.open("GET", url, true); 
    http.onreadystatechange=function() { 
    if(http.readyState == 4) { 
      //alert(http.responseText); 
      //var response = http.responseText; 

       document.getElementById('locationcity').innerHTML = http.responseText; 
      //alert(http.responseText); 

    } 
    } 
    http.send(null); 


} 



//////////////////////////////// 

이다. 목록을 필터링하면이 요소를 덮어 쓰고 새로 만든 선택은 수신기를 수신하지 않습니다.

이 그것을 해결하기 위해 여러 가지 방법이 될,하지만 당신은 이미 jQuery를 사용, 그래서 jQuery의 on() 대신 google.maps.event.addDomListener를 사용하는 것이 좋습니다 것입니다 수 있습니다

jQuery(document).on('change','#city', 
    function(){ 
    //your code 
    } 
); 
+0

당신이 rockstar..thanks은 톤입니다 – San

관련 문제