How to assign a value to a div (change the original Div value)

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.