User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the JavaScript / DHTML / AJAX section within the Web Development category of DaniWeb, a massive community of 391,633 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,793 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our JavaScript / DHTML / AJAX advertiser: Lunarpages Web Hosting

How to retain the disable state of the button after page refreshing

Join Date: Jun 2006
Location: India
Posts: 6,774
Reputation: ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold ~s.o.s~ is a splendid one to behold 
Rep Power: 23
Solved Threads: 330
Moderator
Featured Poster
~s.o.s~'s Avatar
~s.o.s~ ~s.o.s~ is offline Offline
Rebellion Revamped

Re: How to retain the disable state of the button after page refreshing

  #3  
Sep 9th, 2007
Use the 'onload' event handler for this task. This way, as soon as the document / body is loaded, the button will be in disabled state.
<html>
<head></head>
<body onload="funcToDisable();">
</body>
</html>

Here the 'functionToDisable()' will contain the action which you need to perform when the document loads.

That all being said, you should realize that the HTTP is a stateless protocol so you can't keep the button enabled on the first try and disabled on all consecutive reloads since there is way of knowing it. Your best bet would be to keep a flag at the server which will keep track whether its the users' first visit or not and act accordingly.
Last edited by ~s.o.s~ : Sep 9th, 2007 at 12:33 pm.
"I don't accept change. I don't deserve to live."

"Working a real job is a win if you're lazy, greedy, or unmotivated. If you're average, you fit right in. And if you're above average, the basic terms of employment and premise of the arrangement is against your interests."
Reply With Quote  
All times are GMT -4. The time now is 1:01 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC