今天遇到一个问题,想在点一个按钮的时候改变div的值,具体代码如下

 

   
  function exit(id)
  {
      
var   oRoot;   
      
var   xmldoc=new   ActiveXObject("MSXML2.DOMDocument");   
      xmldoc.async
=false;   
      xmldoc.load(
"aa.xml");
      
var   AttNode=xmldoc.selectSingleNode("//MaterialClasses/MaterialClass[@MaterialClassCode='"+id+"']/@Description").text; 

      document.getElementById(
"Question").innerHTML=AttNode;
  }
  
</script> 
</head>

<body>

<div align="center">
<form action="" method="post">
<%
    
Randomize
    C1
=Int((70-0+1)*Rnd+0)
    C2
=Int((70-0+1)*Rnd+0)
    
'取出0到70的随机数,判断如果小于10的话,前面填零
    if C1=C2 then
        
Randomize
        C2
=Int((70-0+1)*Rnd+0)
    
end if
    
if C1<10 then
        C1
="0"&C1
    
End if
    
if C2<10 then
        C2
="0"&C2
    
End if
%>

<table>
<tr>
<td background="q1.gif" width="16" height="8"><href="javascript:exit(<%=C1%>)"><%=C1%></a></td>
<td background="q1.gif" width="16" height="8"><href="xml.asp?id=<%=C1%>"><%=C1%></a></td>
<td background="q1.gif" width="16" height="8"><href="xml.asp?id=<%=C2%>"><%=C2%></a></td>
</tr>
</table>

<p>&nbsp;  </p>
<p>
<input   type="button"   name="b1"   value="取值"   onclick="getValue()">
<input type="submit" value="刷新">
</p>
</form>
</div>


<div id="Question" name="Question"  align="Question" >

</div>
</body>
</html>

执行exit函数时候,取出xml文件中的数据,并且将取出的数据给div

已开始的时候一直认为document.getElementById("Question").value=AttNode;就对了,可是总是出错,也用Bynames,都不行,最后发现不能用value,必须用innerHTML属性才行。

相关文章: