|
查看: 855|回复: 9
|
同一個page,不可以放兩個<div>
[复制链接]
|
|
|
我在做php
在一個 html 設 兩個 <div>
id 不同 ,打算做 ajax 效果
但兩個效果都出現在最后一個 <div > 的地方
為什麼 ??  |
|
|
|
|
|
|
|
|
|
|
发表于 1-11-2008 11:58 AM
|
显示全部楼层
当然可以多过一个 DIV
你的问题应该是 javascript 没有写好, ajax 都 update 去同一个 ID 的 DIV 了 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-11-2008 12:20 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 1-11-2008 12:26 PM
|
显示全部楼层
放完整一點的code.... |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-11-2008 12:48 PM
|
显示全部楼层
-------------------------------------------------- HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script src="selectb.js"></script>
<script src="selectm.js"></script>
</head>
<body color: Red;">showBrand(this.value)">
<table width="600" border="1" align="center">
<tr>
<td align="left" valign="top">
</td>
</tr>
<tr><td>11<div id="selectHint"><b>Motorhere.</b></div>
</td></tr>
<tr>
<td>22<div id="txtHint"><b>Motorcycle info will be listed here.</b></div></td>
</tr>
</table>
<p> </p>
</body>
</html>
------------------------------------- JS 兩個JS都一樣
var xmlHttp
function showBrand(str)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
{
alert ("Browser does not support HTTP Request")
return
}
var url2="getb.php"
url2=url2+"?q="+str
url2=url2+"&sid="+Math.random()
xmlHttp.onreadystatechange=stateChanged
xmlHttp.open("GET",url2,true)
xmlHttp.send(null)
}
function stateChanged()
{
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
document.getElementById("selectHint").innerHTML=xmlHttp.responseText
}
}
function GetXmlHttpObject()
{
var xmlHttp=null;
try
{
// Firefox, Opera 8.0+, Safari
xmlHttp=new XMLHttpRequest();
}
catch (e)
{
// Internet Explorer
try
{
xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
}
catch (e)
{
xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
}
}
return xmlHttp;
} |
|
|
|
|
|
|
|
|
|
|
发表于 1-11-2008 02:07 PM
|
显示全部楼层
同時間只能call一個XMLHttpRequest...
為什麼不把result放在同一個的div?
有很多沒有關係多餘的syntax
貌似是參考 w3 的...
php那邊像它那樣寫比較好 |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-11-2008 02:15 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|
发表于 1-11-2008 02:42 PM
|
显示全部楼层
onload那個太不實際了
要做的話要弄binding
如果是用jquery的話
可以輕易做到... |
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-11-2008 03:52 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
|
|

楼主 |
发表于 1-11-2008 03:54 PM
|
显示全部楼层
|
|
|
|
|
|
|
|
| |
本周最热论坛帖子
|