【发布时间】:2014-10-18 05:34:57
【问题描述】:
我想添加一个关于“类型”列的 if 语句。 .attr('type') 后面有什么东西可以让我为类型指定一个特定的值吗?
$.get("map_process.php", function (data) {
$(data).find("marker").each(function () {
var name = $(this).attr('name');
var address = '<p>'+ $(this).attr('address') +'</p>';
var type = $(this).attr('type');
所以$(this).attr('type'); 正在加载我的表“类型”列值中的所有行。例如:
表格
姓名、地址、类型*
姓名1,地址1,类型A,
姓名2,地址2,类型B,
姓名 3,地址 3,类型 A,
等等
我如何才能“访问”“类型”列的实际值;例如。 $(this).attr('type').<something>('TypeA');
这可能吗?
Edit2:map_process.php 结束
// Select all the rows in the markers table
$query = "SELECT * FROM markers";
$result = mysql_query($query);
if (!$result) {
die('Invalid query: ' . mysql_error());
}
header("Content-type: text/xml");
// Start XML file, echo parent node
echo '<markers>';
// Iterate through the rows, printing XML nodes for each
while ($row = @mysql_fetch_assoc($result)){
// ADD TO XML DOCUMENT NODE
echo '<marker ';
echo 'name="' . parseToXML($row['name']) . '" ';
echo 'address="' . parseToXML($row['address']) . '" ';
echo 'lat="' . $row['lat'] . '" ';
echo 'lng="' . $row['lng'] . '" ';
echo 'type="' . $row['type'] . '" ';
echo 'description="' . parseToXML($row['description']) . '" ';
echo '/>';
}
// End XML file
echo '</markers>';
?>
【问题讨论】:
-
你能说得更具体点吗?你的问题不清楚。
-
你的意思是标签的type:b, input, div ...?
-
对不起,我只是将表格的每个值加载到谷歌地图中,并使用表格“类型”列中的值显示在信息框中。但是比如说,我只想将具有特定值(在表格内)的标记加载到我的地图中。
-
显示
map_process.php的部分结果。 -
您可以将选中的复选框值发送到 map_process.php 并从表中获取选中的值并在 Map 中再次更新标记。
标签: javascript php jquery