473,378 Members | 1,134 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

HELP: document.getElementById("test").innerHTML only works with an alert!

Hi,

I am tring to update some text in a div statement via

document.getElementById("test").innerHTML = "data loaded!"

and

<div id="test">
Loading ... please hold!
</div>

It only updates the text if I include an alert("some message")
statement after the "document.getElementById" line. So, after the alert
comes up and I press the button to close the alert message box, the
text updates!

This is really strange! How can I force this text to update?
I appreciate your help!

Thanks,

Phin

Jul 23 '05 #1
7 8792
Phin wrote:
Hi,

I am tring to update some text in a div statement via

document.getElementById("test").innerHTML = "data loaded!"

and

<div id="test">
Loading ... please hold!
</div>

It only updates the text if I include an alert("some message")
statement after the "document.getElementById" line. So, after the alert
comes up and I press the button to close the alert message box, the
text updates!

This is really strange! How can I force this text to update?
I appreciate your help!


This generally happens if you run the script before the element is
actually loaded in the document - the alert gives the document time to
finish loading so it works then.

Try running the script onload, or put it just after the div 'test'.
--
Rob
Jul 23 '05 #2
if you post the minimum amount of code
in which it still fails, someone here can try
and figure out what the problem is.

Jul 23 '05 #3
Rob,

Thank you for your help.

I ended up using

setTimeout('test()',1000);

and it worked!

Thanks again!

Phin

Jul 23 '05 #4
CF,

What I am trying to do is rather long-winded and would take too much to
explain.
Please see my solution above.

Thank you!

Phin

Jul 23 '05 #5
Phin wrote on 03 jun 2005 in comp.lang.javascript:
What I am trying to do is rather long-winded and would take too much to
explain.
Please see my solution above.


There is nothing "above" in your posting.

This is usenet, so always quote.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)

Jul 23 '05 #6
In regards to Evertjan's post:

For those of you that are not viewing this via google groups, here is
how I solved my problem.

I included the following line:

setTimeout('test()',1000);

//test() is the procedure that I call that does the
document.getElementById("test").innerHTML

Actually, setTimeout('test()',100); worked for me.
Thanks,

Phin

Evertjan. wrote:
Phin wrote on 03 jun 2005 in comp.lang.javascript:
What I am trying to do is rather long-winded and would take too much to
explain.
Please see my solution above.


There is nothing "above" in your posting.

This is usenet, so always quote.

--
Evertjan.
The Netherlands.
(Replace all crosses with dots in my emailaddress)


Jul 23 '05 #7
Phin wrote:
In regards to Evertjan's post:

For those of you that are not viewing this via google groups, here is
how I solved my problem.


Had you read this groups FAQ before posting, you would have never asked
this question as it is covered either in the FAQ or in its links. But
that aside, the group FAQ also covers quoting and top-posting.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Answer:It destroys the order of the conversation
Question: Why?
Answer: Top-Posting.
Question: Whats the most annoying thing on Usenet?
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Shaun | last post by:
Hello! I can't seem to get paths and variables working together: import os a = 'books' os.chdir( '/test') os.mkdir("/test/"a) the last line does not seem to work. os.mkdir(a) makes the...
3
by: Rupa | last post by:
Hi, I'm trying to write an xslt to convert an email in xml format to a new xml format. <descr> <xsl:choose> <xsl:value-of select="body"> </xsl:value-of select> <xsl:when test=" <xsl:value-of...
5
by: kmunderwood | last post by:
I am trying to combine "if match=" and "when test" I am a newbie, and have made both work separately, but I can not seem to combine them. This is my xml("index.xml")page(I can not change this,...
9
by: Marcus Sheen [UK] | last post by:
Have done searches for similar questions, but cannot find anything. Nor can I find any resources via Google (Javascript Source etc). Thinking about implementing a topical "On This Day" feature on...
6
by: chris yoker via DotNetMonster.com | last post by:
hiya, i have an xml doc, and I'd like to assign lookup values. Eg, if the "PRODUCT-TYPE" is 6, then I insert "bike" into the innerText. <code> <rows> <row> <PRODUCT-TYPE>6</PRODUCT-TYPE>...
1
by: GR | last post by:
Hi, I'm trying to create a load test in Visual Studio 2005. 1) Create new test project 2) right click on project and select "Add new test" The only templates that are available are: - Ordered...
6
by: linuxnooby | last post by:
Hi I want a form field to be selected when the page loads. But I get the error message Error: document.getElementById("ff") has no properties any ideas what I am doing wrong? code below
15
oll3i
by: oll3i | last post by:
i'm writing javascript validator and i change input font color when the input is incorrect but i want this input font color to be changed back when the input is correct i cannot do eg var...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.