来自sql server的extraxt数据基于代码javascript [英] extraxt data from sql server Base in a code javascript

查看:112
本文介绍了来自sql server的extraxt数据基于代码javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我在asp.net / c#/ javascript中有一个小项目(攻击谷歌地图)
asp.net页面上的
,我有一个下拉列表:



 <   asp:DropDownList     ID   =  ddlAdr    runat   = 服务器    DataSourceID   =  SDSClient  

< span class =code-attribute> < span class =code-attribute> DataTextField = Name_client DataValueField = ID_client >
< / asp:DropDownList > ;

< div id = button2 class = 按钮 önclick = findAddress();返回false; > Chercher < / div >
< asp:按钮 ID = btnsearch 文字 = 搜索 runat = server CssClass = 按钮 / > // c'est le meme boutton en haut



< javascript代码中






  function  findAddress(){
var address = document 。 getElementById( ddlAdr)。value;

// 脚本使用我们的地理编码器以按地址名称查找位置
geocoder.geocode({' address':address}, function (结果,状态){
if (status == google.maps.GeocoderStatus.OK){< span class =code-comment> // 如果一切正常

// 我们将居中地图
var addrLocation = results [ 0 ]。geometry。 location ;
map.setCenter(addrLocation);

// 将当前坐标存储到隐藏变量
document .getElementById(' lat') .value = results [ 0 ]。geometry。 location 。$ a;
document .getElementById(' lng').value = results [ 0 ]。geometry。 location .ab;

// 然后 - 添加新的自定义标记
< span class =code-keyword> var addrMarker = new google.maps.Marker({
position:addrLocation,
map:map,
title:results [ 0 ] .formad_address
});
} else {
alert(' Geocode由于以下原因未成功:' + status);
}
});
}







 我的 问题    that    下拉  list  < span class =code-leadattribute>显示    name       client    as   a   ClientID   value  I    知道 如何 < span class =code-leadattribute> to   extract     data      已选中 元素 来自  a  < span class =code-leadattribute> database  和: 
- < span class =code-leadattribute> put a marker 根据 提取 地址
- 查看 其他 数据: 名称姓氏,... a infowindow

I 托管 创建 a marker 检索 数据 from a database sql 服务器 传递 < span class =code-leadattribute> a
geocoder
I managed to fill my dropdownlist from BD

解决方案
一个;
document .getElementById(' lng').value = results [ 0 ]。geometry。 location .ab;

// 然后 - 添加新的自定义标记
< span class =code-keyword> var addrMarker = new google.maps.Marker({
position:addrLocation,
map:map,
title:results [ 0 ] .formad_address
});
} else {
alert(' Geocode由于以下原因未成功:' + status);
}
});
}







 我的 问题    that    下拉  list  < span class =code-leadattribute>显示    name       client    as   a   ClientID   value  I    知道 如何 < span class =code-leadattribute> to   extract     data      已选中 元素 来自  a  < span class =code-leadattribute> database  和: 
- < span class =code-leadattribute> put a marker 根据 提取 地址
- 查看 其他 数据: 名称姓氏,... a infowindow

I 托管 创建 a marker 检索 数据 from a database sql 服务器 传递 < span class =code-leadattribute> a
geocoder
I managed to fill my dropdownlist from BD


Hello, I have a small project in asp.net / c # / javascript (to attack a google map)
on a asp.net page, I have a dropdownlist:

<asp:DropDownList ID="ddlAdr" runat="server" DataSourceID="SDSClient"

                                    DataTextField="Name_client" DataValueField="ID_client" >
</asp:DropDownList>
 
<div id="button2" class="button"  önclick="findAddress(); return false;">Chercher</div>
<asp:Button ID="btnsearch" Text="Search" runat="server" CssClass = "button" /> //c'est le meme boutton en haut




in the javascript code:

function findAddress() {
    var address = document.getElementById("ddlAdr").value;
 
    // script uses our 'geocoder' in order to find location by address name
    geocoder.geocode({ 'address': address }, function(results, status) {
        if (status == google.maps.GeocoderStatus.OK) { // and, if everything is ok
 
            // we will center map
            var addrLocation = results[0].geometry.location;
            map.setCenter(addrLocation);
 
            // store current coordinates into hidden variables
            document.getElementById('lat').value = results[0].geometry.location.$a;
            document.getElementById('lng').value = results[0].geometry.location.ab;
 
            // and then - add new custom marker
            var addrMarker = new google.maps.Marker({
                position: addrLocation,
                map: map,
                title: results[0].formatted_address
            });
        } else {
            alert('Geocode was not successful for the following reason: ' + status);
        }
    });
}




My problem is that the dropdown list displays the name of the client, but he as a ClientID value, I do not know how to extract the data for the selected element from a database and:
- Put a marker according to the extracted address
- View other data: name, surname, ... in a infowindow

I managed to create a marker but not retrieve data from a database sql server and pass a geocoder
I managed also to fill my dropdownlist from the BD

解决方案

a; document.getElementById('lng').value = results[0].geometry.location.ab; // and then - add new custom marker var addrMarker = new google.maps.Marker({ position: addrLocation, map: map, title: results[0].formatted_address }); } else { alert('Geocode was not successful for the following reason: ' + status); } }); }




My problem is that the dropdown list displays the name of the client, but he as a ClientID value, I do not know how to extract the data for the selected element from a database and:
- Put a marker according to the extracted address
- View other data: name, surname, ... in a infowindow

I managed to create a marker but not retrieve data from a database sql server and pass a geocoder
I managed also to fill my dropdownlist from the BD


这篇关于来自sql server的extraxt数据基于代码javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆