我正在尝试在 HTML 表单值中回显 div 标记。我无法在不弄乱表单值的情况下显示 div 标签的内容。
<?php echo '<div id="demo"></div>';?>
表单值...
<input type="text" id="term" value="<?php echo '<div id="demo"></div>';?>">
输出的是什么……(表单值里面回显的应该是当前的经纬度)
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta content="text/html; charset=ISO-8859-1" http-equiv="content-type">
<title>Geolocation search</title>
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
<script id="data" type="text/javascript" src="js/search.js" xmlData="data/data.xml"></script>
</head>
<body onload="getLocation()">
<div id="controller">
<label>Search Term:
<input type="text" id="term" value="<?php echo '<div id="demo"></div>';?>">
</label>
<label>
<select name="category" id="category">
<option value="name">Name</option>
</select>
</label>
<input name="Search" type="button" id="searchButton" value="Search">
</div>
<div id="result"> </div>
<?php echo '<div id="demo"></div>';?>
<script>
var x=document.getElementById("demo");
function getLocation()
{
if (navigator.geolocation)
{
navigator.geolocation.getCurrentPosition(showPosition);
}
else{x.innerHTML="Geolocation is not supported by this browser.";}
}
function showPosition(position)
{
x.innerHTML=" " + position.coords.latitude +
"<br> " + position.coords.longitude;
}
</script>
</body>
</html>
是否有其他方法可以从 echo 语句中加载的经度和纬度中呼出?