|
 |
|
เกี่ยวกับ loop for แสดงข้อมูลทีละหลาย record แต่อย่างรู้ว่าเวลาเรากดข้อมูลrecord ใด ให้ alert detail ของ record นั้น |
|
 |
|
|
 |
 |
|
Code
<?
for($i=0;$i<$num1;$i++)
{
$result1=mysql_fetch_array($query1);
$mark_id=$result1['id'];
$lon=$result1['lon'];
$lat=$result1['lat'];
$detail=$result1['detail'];
echo "var mark_id = '$mark_id';";
echo "var detail = '$detail';";
?>
var lon=<?=$lon?>;
var lat=<?=$lat?>;
var size = new OpenLayers.Size(21,25);
var size1 = new OpenLayers.Size(100,50);
var offset = new OpenLayers.Pixel(-(size.w/2), -size.h);
var icon = new OpenLayers.Icon('./images/talk.png',size,offset);
var icon1 = new OpenLayers.Icon('./images/mark/'+mark_id+'.png',size1,offset);
markdetail.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lon,lat),icon1));
markers.addMarker(new OpenLayers.Marker(new OpenLayers.LonLat(lon,lat),icon));
markers.events.register("mousedown", g_markers, function(evt) {
alert(detail);
OpenLayers.Event.stop(evt);
});
<?
}
?>
ตัวอย่างโค๊ดนะคะ
แต่พอเวลาคลิกรูปก่ออกทุกตัว10 ครั้ง
อยากให้คลิกรูปใหนก่ออกdetail -องรูปนั้น
Tag : PHP, JavaScript

|
|
 |
 |
 |
 |
Date :
2012-04-25 10:57:03 |
By :
tai_kook |
View :
1157 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
|
|

|
Load balance : Server 03
|