我正在尝试在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">&nbsp;</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语句中加载的经度和纬度回声吗?

最佳答案

这是“

更改

<input type="text" id="term" value="<?php echo '<div id="demo"></div>';?>">




<input type="text" id="term" value="<?php echo "<div id='demo'></div>";?>">

08-19 10:18