2012-06-25 1 views
0

두 개의 fancybox 모달, 주 및 시가있는 콤보 박스가 있습니다. 상태를 선택한 후 콤보 도시를로드해야합니다. 내 코드 :fancybox 안에 두 번째 콤보 박스로드

<div id="city" class="hide"> 

    <asp:Literal ID="litCity" runat="server"></asp:Literal> 
    <a href="#data">Trocar de Cidade</a> 

</div> 

<asp:UpdatePanel ID="updCity" runat="server" UpdateMode="Conditional"> 
<ContentTemplate> 

    <div id="data" class="hide"> 

    <asp:HiddenField ID="hdnNovaCidade" runat="server" Value="" /> 
    <div class="row"> 

    <label for="drpState">Estado *</label> 
    <asp:DropDownList ID="drpState" runat="server" AutoPostBack="True" > </asp:DropDownList> 

    </div> 

<div class="row"> 

    <label for="drpCity">Cidade *</label> 
    <asp:DropDownList ID="drpCity" runat="server"></asp:DropDownList> 


</div> 

    <input id="btCidade" type="submit" value="Escolher Cidade" /> 

</div> 
</ContentTemplate> 
<Triggers> 

    <asp:AsyncPostBackTrigger ControlID="btCarregaCidade" EventName="Click" /> 

</Triggers> 
</asp:UpdatePanel> 

JQUERY는 어떻게됩니까

$('[id$="drpState"]').change(function() { 

    $('[id$="hdnState"]')[0].value = $(this).val(); 
    $('[id$="btCarregaCidade"]')[0].click(); 

}); 

페이지의 이벤트 버튼 후 다시로드가 fancybox을 닫고 있다는 것입니다. 모달을 닫지 않고 콤보 상자 도시를로드하려면 어떻게해야합니까? 도움을

덕분에 나는이 purpose..here 위해 Ajax를 사용하는 것이 좋습니다

답변

0

는 먼저 ID = "citycontainer"와 상태 선택 상자

$('[id$="drpState"]').change(function() { 
var stid = $(this).val(); 
var cityhtml = ''; 
     //call an ajax function to load the states 
    $.ajax({ 
     url:'Your_url_containing_thephp_function_for_states', 
     data : {'stateid',stid}, 
     dataType:'json', 
     type: "POST", 
     success:function(msg){ 
      cityhtml+='<select id="city">'; 
       if(count(msg)>0){ 
       for(i=0;i<msg.length;i++){ 

      cityhtml+='<option value="'+msg[i]['your_city_id_index']+'">'+msg[i]['your_city_name_index']+'</option>'; 
       } 
      } 
$('#citycontainer').html(cityhtml); 
     }  
}); 


}); 

//State.php (The php side) 

$stateid = $_POST['stateid']; 
$cities = someFuntionReturningCitiesbasedOnstateid($stateid); //must return as array 
echo json_encode($cities);exit; 
근처에 빈 스팬 또는 사업부를 넣어 자세한 코드
관련 문제