473,416 Members | 1,713 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,416 software developers and data experts.

Force drawing changes?

Hi all,
I have a set of Javascript functions that dinamically update the
contents of a HTML <selectelement, depending on the value of another
<select>. For easy understanding: I select a region/state in one
<selectand then I update the list of towns in that region in the
other <select>.

Some regions have lots of towns and there is a little wait until the
browser updates completely the <select>. I want to show a "Loading..."
message, but I cannot make it work.
I try to show/hide a div with this message using its CSS property
display. But the browser only shows that message if I make an
alert("pause") anywhere after I have changed the CSS attribute.
It seems like the alert forces the browser to draw the changes... Is
there any way to force that drawing?

Thanks

Jul 24 '06 #1
3 3211
Some regions have lots of towns and there is a little wait until the
browser updates completely the <select>. I want to show a "Loading..."
message, but I cannot make it work.
I try to show/hide a div with this message using its CSS property
display. But the browser only shows that message if I make an
alert("pause") anywhere after I have changed the CSS attribute.
It seems like the alert forces the browser to draw the changes... Is
there any way to force that drawing?
Hi Ruben,

The problem is that while a script is running the browser is less likly
to update the screen contents. An alert pauses the script, giving the
browser time to redraw. Best thing to do would be to use a timer to
disptach the actual command to load the content. So:

function searchTown() {
...show div layer
window.setTimeout('updateTown()', 10);
}

function updateDown() {
... expenstive routine
... hide div layer
}

Good luck,
Vincnet
Jul 24 '06 #2
beatdown wrote:
Hi all,
I have a set of Javascript functions that dinamically update the
contents of a HTML <selectelement, depending on the value of another
<select>. For easy understanding: I select a region/state in one
<selectand then I update the list of towns in that region in the
other <select>.

Some regions have lots of towns and there is a little wait until the
browser updates completely the <select>. I want to show a "Loading..."
message, but I cannot make it work.
I try to show/hide a div with this message using its CSS property
display. But the browser only shows that message if I make an
alert("pause") anywhere after I have changed the CSS attribute.
It seems like the alert forces the browser to draw the changes... Is
there any way to force that drawing?
Hi,

I never saw that behaviour before, but that doesn't stop me giving advise
about it.
;-)

You could try to give the browser a pause by strating your heavy calculation
a little later.
use window.setTimeout("heavyCalc();",50);

the 50 are the number of milliseconds before the function named heavyCalc()
is called.

Maybe that helps, give it a shot.

Regards,
Erwin Moller
>
Thanks
Jul 24 '06 #3
Vincent van Beveren said the following on 7/24/2006 10:26 AM:
>Some regions have lots of towns and there is a little wait until the
browser updates completely the <select>. I want to show a "Loading..."
message, but I cannot make it work.
I try to show/hide a div with this message using its CSS property
display. But the browser only shows that message if I make an
alert("pause") anywhere after I have changed the CSS attribute.
It seems like the alert forces the browser to draw the changes... Is
there any way to force that drawing?

Hi Ruben,

The problem is that while a script is running the browser is less likly
to update the screen contents.
Except that it's not "less likely", it flat out won't update it until
the script finishes. Adding the setTimeout doesn't "give it time to
update", it finishes the script block, then it updates, then it executes
a second script block.

--
Randy
comp.lang.javascript FAQ - http://jibbering.com/faq & newsgroup weekly
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Jul 24 '06 #4

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

Similar topics

5
by: Rob Mayo | last post by:
How can I force a MeasureItem message for an owner-dramn menu item? Here is the dilemma. I wrote a lovely little Component for owner-drawing all the menus on a form and making them look like...
4
by: funcSter | last post by:
Hey, got a prob which is driving me nuts! I'm trying to resize the resolution of an image as well as it's pyhsical byte size. I've got: byte bytImage = null; System.Drawing.Image imgImage =...
3
by: Arulraja | last post by:
Hello, I have created 2 custom server controls, The parent custom control contains multiple child custom controls. The Child control has a button on it. If I Click the button control, it...
7
by: OHM | last post by:
Hi Guys, I wouldnt normally ask for help on this but Im really strapped for time. Does anyone know how I can force characters in a DataGrid cell to uppercase as they are typed. Cheers - OHM
1
by: astro | last post by:
Is there a command/syntax that will force a given datagrid to submit it's changes to it's dataset? I know the currencymanager is responsable for this.......just can't get it to work. I've...
0
by: Dean Richardson | last post by:
Hello, Is there anyway that I could embed an autosketch drawing to an ASP.NET window? What I need to do is to allow users to open the drawing and then make changes and then save it. This should...
9
by: davetelling | last post by:
I am not a programmer, I'm an engineer trying to make an interface to a product I'm designing. I have used C# to make a form that interrogates the unit via the serial port and receives the data. I...
11
by: dongarbage | last post by:
Hi there, I'm very much a C# novice. How do you do freehand drawing on a panel with a mouse in c#? Thanks, Don
0
by: Smith.BarryP | last post by:
I have a program that uses displays data with scientific units. The user can select which particular unit they wish to see the values in (Kelvin, Celsius, etc...). I have handled this by...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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...
0
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,...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.