javascript innerHTML 能不能用数组
<scriptlanguage="javascript"type="text/javascript">varxmlHttp=false;try{xmlHttp=newAc...
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer(aa,cc) {
bb=cc
// alert(ProdId);
var url = "66.asp?name=" + aa;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
//alert(updatePage);
xmlHttp.send(null);
//alert("updatePage");
}
function updatePage() {
//var test="test"+bb;
alert(bb);
var test=new Array();
if (xmlHttp.readyState < 4) {
test.innerHTML="正在读取价格";
}
if (xmlHttp.readyState == 4) {
var response= xmlHttp.responseText;
test.innerHTML=response;
}
}
</script>
<input name="ProdId" type="button" onClick="callServer('20002718',0);" value="提交" size="20" maxlength="15"/>
<span id="test[0]">555</span><br>
下面这一行能不能改成数组test[bb]
test.innerHTML=response; 展开
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer(aa,cc) {
bb=cc
// alert(ProdId);
var url = "66.asp?name=" + aa;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
//alert(updatePage);
xmlHttp.send(null);
//alert("updatePage");
}
function updatePage() {
//var test="test"+bb;
alert(bb);
var test=new Array();
if (xmlHttp.readyState < 4) {
test.innerHTML="正在读取价格";
}
if (xmlHttp.readyState == 4) {
var response= xmlHttp.responseText;
test.innerHTML=response;
}
}
</script>
<input name="ProdId" type="button" onClick="callServer('20002718',0);" value="提交" size="20" maxlength="15"/>
<span id="test[0]">555</span><br>
下面这一行能不能改成数组test[bb]
test.innerHTML=response; 展开
3个回答
展开全部
楼主貌似是想把response的内容插入到数组的某个元素中而不是整个数组内吧?test.innerHTML=response;改成test[bb].innerHTML=response;是完全可以的,只要bb不溢出就可以了
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer(aa,cc) {
var url = "66.asp?name=" + aa;
bb=cc;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
var test=document.getElementById("test"+bb);
if (xmlHttp.readyState < 4) {
test.innerHTML="正在读取价格";
}
if (xmlHttp.readyState == 4) {
var response= xmlHttp.responseText;
test.innerHTML=response;
}
}
</script>
<input name="ProdId" type="type" size="20" maxlength="15" onClick="callServer();"/>
<input name="ProdId" type="button" onClick="callServer('20002718',0);" value="提交" size="20" maxlength="15"/>
<span id="test0">555</span><br>
<input name="ProdId" type="type" size="20" maxlength="15" onClick="callServer();"/>
<input name="ProdId" type="button" onClick="callServer('20002718',1);" value="提交" size="20" maxlength="15"/>
<span id="test1">555</span><br>
<script language="javascript" type="text/javascript">
var xmlHttp = false;
try {
xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
try {
xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
} catch (e2) {
xmlHttp = false;
}
}
if (!xmlHttp && typeof XMLHttpRequest != 'undefined') {
xmlHttp = new XMLHttpRequest();
}
function callServer(aa,cc) {
var url = "66.asp?name=" + aa;
bb=cc;
xmlHttp.open("GET", url, true);
xmlHttp.onreadystatechange = updatePage;
xmlHttp.send(null);
}
function updatePage() {
var test=document.getElementById("test"+bb);
if (xmlHttp.readyState < 4) {
test.innerHTML="正在读取价格";
}
if (xmlHttp.readyState == 4) {
var response= xmlHttp.responseText;
test.innerHTML=response;
}
}
</script>
<input name="ProdId" type="type" size="20" maxlength="15" onClick="callServer();"/>
<input name="ProdId" type="button" onClick="callServer('20002718',0);" value="提交" size="20" maxlength="15"/>
<span id="test0">555</span><br>
<input name="ProdId" type="type" size="20" maxlength="15" onClick="callServer();"/>
<input name="ProdId" type="button" onClick="callServer('20002718',1);" value="提交" size="20" maxlength="15"/>
<span id="test1">555</span><br>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询