473,756 Members | 3,655 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to express progress of longer run of JS?

Hi,
I check data validity in html form by JS. Something like

for (i=0; i<document.for m[0].elements.lengt h; i++) {
chechkValidity( i);
}

Unfortunately, the form[0] has about two thousands elements (it is
statistical questioning form for companies) and execution of this one
cycle takes about twenty seconds.

The problem is, that during these 20 seconds the browser "freezes":
The button activating the cycle disappears and the mouse pointer
doesn't change into "watch" (sandglass) showing that something is
being carried out.

Although after the 20s everything is ok, it is not the nicest behavior
of the form. I don't assume somebody is so impatient to restart during
those 20 seconds. I just want to minimize the users' swearing on my
address and tha's why my question:

??? How to show the progress of that cursed for-cycle?

Thanks
Martin
Jul 23 '05
13 2195
On Tue, 18 May 2004 19:06:03 +0100, Richard Cornford wrote:
Andrew Thompson wrote:
<snip>
(shrugs) Seems to work in both IE6 and
Moz 1.3 on XP. Did I miss something (still)?


We try not to think in terms of "both browsers" these days.


Aaah well. The only ones I had immediate
access to. I'd have to hunt down and install
NN 4.7, ..or Lynx off the filesystem. Just
checking now I also see 'pheonix' (shrugs
vaguely).

I know I have a CD with an older version
of Opera tucked away somewhere...

(wanders off, muttering..) ;-)
Jul 23 '05 #11
Martin Mrazek wrote:
Hi,
I check data validity in html form by JS. Something like

for (i=0; i<document.for m[0].elements.lengt h; i++) {
chechkValidity( i);
}


I'd suggest:

1. Create an array, e.g. myformstatus[]

1a. Set a new variable to setInterval("is Complete(myform )",20);

2. have a for loop disabling all the form elements, assuming that you
don't want user interaction until the process is complete, just user
feedback. Populate each element of myformstatus[] with a default value,
e.g. null.

3. use your loop with something like myform[i] =
setTimeout(chec hkValidity(i),1 0); so your function is called and the
browser is only hanging for the period of one execution of
chechkValidity( ) once.

[Note your setTimeout could be
("chechkValidit y(i);chechkVali dity(i+1);chech kValidity(i+2); ",10"); so
that these are executed in blocks rather than just one at a time,
depending on how intensive each call is...]

4. In chechkValidity( ), set myformstatus[i] to some other default value,
e.g. "done"

5. Create a function isComplete() which goes through myformstatus[] to
check that all elements have a value of "done". If so, clear the
setInterval() and then have a for loop reenabling all form elements.

Then in your step 3 or 4 you can do whatever feedback to the user you can.

Note this may cause the overall process to take _longer_, but if you do
it in one for loop as you've described you'll hit three problems:

1. It may cause the browser to freeze so long that the browser offers
the option for the user to abandon it, thus potentially causing all
manner of state-related problems. I've found that recent builds of
Mozilla seem to have shortened this time considerably, but there's no
easy way I've found of pre-determining how long this actually is.

2. You won't be able to get feedback to the user, as the browser needs
time to breathe between bursts of Javascript...

3. A browser freeze may be considered by the user as a browser crash!

Just my thoughts - I've not tested this out but it seems to make sense,
at least to me!

Thanks,

Ian
Jul 23 '05 #12
On Tue, 18 May 2004 20:14:34 +0100, Ian Richardson
<za*****@chaos. org.uk> wrote:
Martin Mrazek wrote:
Hi,

3. use your loop with something like myform[i] =
setTimeout(che chkValidity(i), 10); so your function is called and the
browser is only hanging for the period of one execution of
chechkValidity () once.


So on win98 this will add a minimum of 106 seconds? (53ms minimum
setTimeout resolution *2000 items, or is my maths out?)

(not that I don't disagree with the need to use setTimeout, but
remember it's a lot of overhead.)

Jim.
--
comp.lang.javas cript FAQ - http://jibbering.com/faq/

Jul 23 '05 #13
JRS: In article <40************ ****@news.indiv idual.net>, seen in
news:comp.lang. javascript, Jim Ley <ji*@jibbering. com> posted at Wed, 19
May 2004 22:53:18 :

So on win98 this will add a minimum of 106 seconds? (53ms minimum
setTimeout resolution *2000 items, or is my maths out?)


More exactly, (2000*) 54.9255 milliseconds. 86400000 / 0x1800B0.

Anyone know of javascript systems where the time quantum is NOT either
55 ms (possibly rounded to 50/60) or 10 ms? RSVP.

--
© John Stockton, Surrey, UK. ?@merlyn.demon. co.uk Turnpike v4.00 MIME. ©
Web <URL:http://www.merlyn.demo n.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demo n.co.uk/programs/> - see 00index.htm
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Jul 23 '05 #14

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

Similar topics

0
1406
by: mirandacascade | last post by:
O/S - Windows XP Home with Service Pack 2 Vsn of Python: 2.4 (from ActiveState) This question is with regard to the progress bar controls that are in the file status.py. On my workstation, status.py is located in the: c:\python24\lib\site-packages\pythonwin\pywin\dialogs\ folder.
1
2853
by: Matt Alanzo | last post by:
On another newsgroup an Access knowledgable party posted: >You should be able to connect an Access ADP to an existing SQLExpress >database running in SQLS 2000 compatibility mode. The only thing you >won't be able to do is access any of the design surfaces for SQLS >objects in the ADP. I checked with the Access team on this :-) > I appealed for clarification but without reply. Maybe somone on this newsgroup can provide insight.
1
1652
by: Ziggy | last post by:
Please excuse this elementary question...but I am just dumb.... I have taken a simplistic Dialog Box and added a Progress Control. When I did that, my Dialog Box was no longer able to intialize using the DialogBox macro. If I remove the Progress Control from the form, the form displays appropriately. Is there something that needs to be done in addition to providing a callback
5
1752
by: Lloyd Sheen | last post by:
I used the betas and they had lots of problems. Well the release is here and is crap. I execute a program and then on second execute (no changes to the source) and I get the following: An error occurred creating the form. See Exception.InnerException for details. The error is: Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "ObjectShower.ObjectShower.resources" was correctly...
11
4872
by: processoriented | last post by:
Hi, I'm something of a noob at this, but here it is... I have an app that fills a dataset from a SQL database, and then writes the dataset to an xml file. Everything is a SELECT query... I am basically just replicating data to the local user's machine, and several of the queries take a long time to run over VPN connection to the database (the way most of my users will use it), so I sank the whole operation into a BackgroundWorker so that...
14
2293
by: Professor Yonce | last post by:
I have made form for E-Mail. I have entered code but the Import system does not work. It has squiggly line underneath it showing it is not communicating. It Will not build. Public Class Form3Bio1 System.Net.Mail.SmtpClient Imports System.Net.Mail ' This line before ' does not work. I have the rest of code to try if and when I am able to get System working. ' I XXX out certain entrys below just for this publication.
5
1351
by: Marco Trapanese | last post by:
Hi, I have a small application which uses a connection to a SQL database. Using clickonce I make the deploy folder. Well, the target PC is old (600 MHz, 256 MB RAM, WinXP) but it should be ok for my application. The framework is installed, but while deploying my program, it want to install Windows Installer 3.1 and SQL Server Express. The former has no problem but the latter goes in timeout after downloading and installing up to 100%...
8
2081
by: Paulo | last post by:
Hi, while the user is uploading a file, is possible to show a progress bar? Using VS 2005 Asp.net 2.0 C# Thanks!
1
1394
by: coolsti | last post by:
Here is a strange occurrance: I start up my Visual C# 2008 Express program today, start a new project, put a bunch of controls on a form, save the project, and then close the program (for a break) and start it up again after. I reload my project, and it is empty. No form, no controls. I try again. And again. The same continues to happen. Anyone know what can be wrong? I did not register my Visual C# 2008 Express as it had been warning me...
0
9275
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10034
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9872
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8713
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3805
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3358
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2666
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.