如何给一个div赋值(改变div原来的值)

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

 

ContractedBlock.gif ExpandedBlockStart.gif Code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title></title>
<script   language="javascript">   
  
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属性才行。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值