Please Wait Image not showing until validation complete

S

stefanomarge

This is my javascript function:

function check_update(subCheked){

document.getElementById('pleasewaitScreenTop').style.visibility="visible";

var formLength = document.form1.elements.length;
for(var c = 0; c < formLength; c++){
var searched = document.form1.elements[c].name;

if(document.form1.elements[c].type != "hidden"){
//do something
}
}
if(indError != 0){

document.getElementById('pleasewaitScreenTop').style.visibility="hidden";
}
return ret;
}


this is my html code

<div id="pleasewaitScreenTop" class="waiting">
<img src="../img/loading.jpg" />
</div>


1) The "loading.jpg" img appear on my page just at the end of
"check_update function" execution.
I want the image appear immediately when the "check_update function"
beginning to run.

2) Also, can I reduce the "document.form1.elements[c]" array to have
the same array just with not hidden type elements?

Could someone help me?

Thanks
 
S

stefanomarge

(e-mail address removed) said the following on 2/21/2008 7:06 AM:


This is my javascript function:
function check_update(subCheked){
document.getElementById('pleasewaitScreenTop').style.visibility="visible";

var formLength = document.form1.elements.length;
for(var c = 0; c < formLength; c++){
var searched = document.form1.elements[c].name;
if(document.form1.elements[c].type != "hidden"){
//do something
}
}
if(indError != 0){
document.getElementById('pleasewaitScreenTop').style.visibility="hidden";
}
return ret;
}
this is my html code
<div id="pleasewaitScreenTop" class="waiting">
<img src="../img/loading.jpg" />
</div>
1) The "loading.jpg" img appear on my page just at the end of
"check_update function" execution.
I want the image appear immediately when the "check_update function"
beginning to run.

The reason is the display doesn't update until the script finishes
executing. What you will have to do is have two functions:

function function1(){
//Show the image in this function.
//Then use setTimeout to call the second function.

}

function function2(){
//all your processing here.
//hide the image here.

}
2) Also, can I reduce the "document.form1.elements[c]" array to have
the same array just with not hidden type elements?

No. You could loop through it and get a collection of your own but it is
simpler to just check the type of the input and ignore hidden inputs.
Could someone help me?

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ -http://jibbering.com/faq/index.html
Javascript Best Practices -http://www.JavascriptToolbox.com/bestpractices/


Thank you very much for your reply.


I do in the following way:

function check_update(subCheked){


document.getElementById('pleasewaitScreenTop').style.visibility="visible";
setTimeout("check_update2('"+subCheked+"')",200);

}


function check_update2(subCheked){

var formLength = document.form1.elements.length;
for(var c = 0; c < formLength; c++){
var searched = document.form1.elements[c].name;

if(document.form1.elements[c].type != "hidden"){
//do something
}
}
if(indError != 0){

document.getElementById('pleasewaitScreenTop').style.visibility="hidden";
}
return ret;
}


but it is still not working.
Do you know why?

Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,566
Members
45,041
Latest member
RomeoFarnh

Latest Threads

Top