可能重复:
Assign Vb.net loop variable values to javascript Array
我有DB值的服务器端循环,我想在客户端数组中传递它们 我的服务器端代码如下:
Dim GPS As New String("")
Dim STATION As new String("")
For I = 0 To ds.Tables("GPS").Rows.Count - 1
I = ds.Tables("GPS").Rows.Count - 1
GPS = ds.Tables("GPS").Rows(I).Item("GPS_ONE")
STATION = ds.Tables("GPS").Rows(I).Item("STA_NAME")
Next I
客户端阵列是
store_locations = [
new google.maps.LatLng(31.204549793299,72.264183974237),
new google.maps.LatLng(31.23004996385,72.282225091978),
new google.maps.LatLng(31.148218,72.224542),
new google.maps.LatLng(31.2330555556,72.3330555556)
];
for(i=0; i<store_locations.length; i++)
{
markers[i] = new google.maps.Marker(
{
position: store_locations[i],
map: map,
draggable:true,
icon:image,
title: 'ADEEL' + (i+1)
});
}
现在我想从服务器端GPS变量获取store_locations。有没有办法将服务器端GPS传递到客户端store_location,以便来自循环的GPS的所有值都应分配给数组。
我已经做了一些事情但是失败了
var GPS = '<%=GPS %>'.replace(/ /g, '').split(',');
GPS_AR = new array();
GPS_AR = [
new google.maps.LatLng(GPS[0], GPS[1])
];