Click here to Skip to main content
15,887,214 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here i bind data from database & onselectedindexchanged databind option.
I want to call function of javascript upon given.
I've tried it but drop down list not working:


JavaScript
script type="text/javascript">
        $(document).ready(function () {
            $("#ddlpostoffice").onchange(function () {
                var geocoder = new google.maps.Geocoder();
                var strSearch = document.getElementById('txtSearch').value;
                geocoder.geocode({ 'address': strSearch }, function (results, status) {
                
                        map = new google.maps.Map(document.getElementById("Map_Div"), myOptions);
                        var marker = new google.maps.Marker({
                            position: new google.maps.LatLng(x, y),
                            map: map,
                            title: strSearch
                        });
                        s
                        var infowindow = new google.maps.InfoWindow({
                            content: strSearch
                        });
                        infowindow.open(map, marker);
                        google.maps.event.addDomListener(window, 'load');
                    } else {
                        document.getElementById('txtSearch').value = "This Location Map Not Found";
                    }
                });
            });
        });
    </script



 asp:DropDownList CssClass="select" ID="ddlpostoffice" runat="server" 
              AutoPostBack="True"    onselectedindexchanged="ddlpostoffice_SelectedIndexChanged" onchange="return false;"   
Posted
Updated 16-Dec-15 2:48am
v3
Comments
7045Jeegnesh 16-Dec-15 8:10am    
does page reloaded After Selection?
7045Jeegnesh 16-Dec-15 8:11am    
if Yes
then Put "Return false" @ end
[no name] 16-Dec-15 8:49am    
sir i am already do but it is not working of database binding & no work function
F-ES Sitecore 16-Dec-15 9:27am    
You are attaching to the client-side change event for the dropdown, and if you have autopostback set to true so you can run the server-side change event then both events are happening. You change the dropdown, your javascript runs, does something, then the page is posted back so your server-side event runs, that generates a new page which removes anything you did on the client-side event.

Either you want the client event to happen and not the server event, the server event but not the client, or you want both to happen but you want the javascript to happen *after* the server event. Each scenario has a different solution so you'll need to explain what you want in more detail.
xszaboj 16-Dec-15 11:20am    
are you trying to do this?
https://developers.google.com/maps/documentation/javascript/examples/geocoding-simple

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900