Wait cursor

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
asai
Forum Commoner
Posts: 43
Joined: Tue May 04, 2010 6:24 am
Location: Norway

Wait cursor

Post by asai »

Hi,

I have a form where the user input some variables.
On submit a new page opens, where I have several sql querys.
In the end of this page the results of the querys is shown in a table.
All this works very nice, however all these querys takes a few seconds.
From the moment you press the submit button, it seems like nothing is happening, like the webpage is frozen.
Is there a way to either show a wait cursor or show a animated gif?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Wait cursor

Post by requinix »

Is there any way you can speed up the queries? Do you know why they're taking so long?

If you can't, which should be the first thing you try, there are a few options. Changing the mouse cursor is as simple as

Code: Select all

body { cursor: wait; }
which you can apply with a class or by setting the style directly. You should also put something more obvious on the page, like a busy indicator (spinning circles are popular these days), and you probably should also disable the form so the user cannot submit the form a second time when they get impatient.

But check the queries first.
shiningsun
Forum Newbie
Posts: 11
Joined: Fri Feb 10, 2017 6:49 am

Re: Wait cursor

Post by shiningsun »

yes. the best way is to set changing of cursor from the moment when an event happens
it is easy can be done on jquery
asai
Forum Commoner
Posts: 43
Joined: Tue May 04, 2010 6:24 am
Location: Norway

Re: Wait cursor

Post by asai »

requinix wrote:Is there any way you can speed up the queries? Do you know why they're taking so long?

If you can't, which should be the first thing you try, there are a few options. Changing the mouse cursor is as simple as

Code: Select all

body { cursor: wait; }
which you can apply with a class or by setting the style directly. You should also put something more obvious on the page, like a busy indicator (spinning circles are popular these days), and you probably should also disable the form so the user cannot submit the form a second time when they get impatient.

But check the queries first.
Yes this is probably a good solution, but where do I put it?
In the page where the users data and submit button or the file containing the querys?
I tried from the first page, but nothing happened. Could be something wrong with my code..
I want the cursor to change when the submit button is pressed and change back to normal when the second page is finished loading.
asai
Forum Commoner
Posts: 43
Joined: Tue May 04, 2010 6:24 am
Location: Norway

Re: Wait cursor

Post by asai »

Solved it :D

Heres my solution:

Code: Select all

<input type="submit" value="Show result" onclick="ChangeCursor()">
And this:

Code: Select all

<script>
function ChangeCursor(){
document.body.style.cursor = 'wait';
}
</script>
Post Reply