Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

javascript mouse hourglass

Status
Not open for further replies.

caesarkim

Programmer
Oct 30, 2003
56
0
0
US
I have an issue for making a mouse hourglass and normal status.

I have about 1000 checkboxes. I want to have a user check all checkboxes and show a mouse hourglass while they are being checked and have the mouse go back to normal after done. I used document.body.style.cursor='wait' or
for (var i=0;i < document.all.length; i++)
{
document.all(i).style.cursor = 'wait';
} before the process and

document.body.style.cursor='default' or

for (var i=0;i < document.all.length; i++)
{
document.all(i).style.cursor = 'default';
}
to see if it works. but it doesn't make any difference. the page that I want to implement is included in the multiple frames. I am using IE 5.5+.

anybody know how to force the hourglass?

I'd appreciated about the good advice in advance.

 
Clunky but working in IE6:

Code:
<html>
<head>
<script>
var cbs = new Array(); //holds checkboxes

//called onload; collects checkboxes into array
[green]function collectEm()[/green]
{
 cbs = document.getElementsByTagName("INPUT");
}//end collectEm()

var allChecked = false; //global flag

//starts checking process
[blue]function checkAll()[/blue]
{
 //sets cursor over body AND over button
 document.body.style.cursor = 'wait';
 document.forms[0].myButton.style.cursor = 'wait';

 //sometimes using setTimeout(...) makes things work!
 //WITHOUT it, in this case, checking of boxes begins
 // before cursor style is updated.
 [red]setTimeout('finishJob();', 0);[/red]
}//end checkAll()

[red]function finishJob()[/red]
{
 var cbslength = cbs.length;
 for(i=0; i<cbslength; i++)
 {
   cbs[i].checked = !allChecked;
 }//end for

 allChecked = !allChecked; //switch flag

/*
 JavaScript is just barely faster than screen buffer in this case.
  This makes it look like cursor changes back in synch with
  JavaScript.
*/

 setTimeout("document.body.style.cursor = 'default';document.forms[0].myButton.style.cursor = 'default';",200);
}//end finishJob()
</script>
</head>
<body [green]onload='collectEm();'[/green]>
<form>
<script>
for(var i=0; i<5000; i++)
{
 document.write("<input type='checkbox' />")
}
</script>
<br />
<button name='myButton' [blue]onclick='checkAll()'[/blue] value='checkall' />
</form>
</body>
</html>

Maybe there's something here you can use.

--Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
I didn't want to get Red Flagged! :)

--Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top