I encountered a problem today. I want to change the DIV value when I click a button.CodeAs follows:
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;
}< br> 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 )
' Obtain the random number ranging from 0 to 70. If the number is less than 10, fill in the previous zero.
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" > < A Href = "Javascript: exit (<% = C1 %> )" > <% = C1 %> </ A > </ TD >
< TD Background = "Q1.gif" Width = "16" Height = "8" > < A Href = "XML. asp? Id = <% = C1 %>" > <% = C1 %> </ A > </ TD >
< TD Background = "Q1.gif" Width = "16" Height = "8" > < A Href = "XML. asp? Id = <% = C2 %>" > <% = C2 %> </ A > </ TD >
</ Tr >
</ Table >
< P > & Nbsp; </ P >
< P >
< Input Type = "Button" Name = "B1" Value = "Value" Onclick = "Getvalue ()" >
< Input Type = "Submit" Value = "Refresh" >
</ P >
</ Form >
</ Div >
<DivID= "Question"Name= "Question"Align= "Question" >
</Div>
</Body>
</Html>
When the exit function is executed, the data in the XML file is taken out and the retrieved data is sent to the DIV
The document. getelementbyid ("Question "). value = attnode; that's right. But there are always errors, and bynames cannot be used. At last, we found that the value cannot be used and the innerhtml attribute must be used.