•
•
•
•
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 456,597 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 3,423 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
Views: 1519 | Replies: 4
![]() |
| |
•
•
Join Date: Sep 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Experts here,
Pls help.
when I disable the button using the code
document.getElementById("mybutton").disable=true;
it is disabling perfectly but when the page gets refreshed again it comes
to enable position
so, I need a code even when the refreshing the page also my button is in disable position.
Thanks and Regards,
Srinivas yadav.
Pls help.
when I disable the button using the code
document.getElementById("mybutton").disable=true;
it is disabling perfectly but when the page gets refreshed again it comes
to enable position
so, I need a code even when the refreshing the page also my button is in disable position.
Thanks and Regards,
Srinivas yadav.
Last edited by srinivaskota : Sep 9th, 2007 at 8:45 am.
•
•
Join Date: Sep 2007
Posts: 4
Reputation:
Rep Power: 0
Solved Threads: 0
Hi Experts here,
Pls help.
when I disable the button using the code
document.getElementById("mybutton").disable=true;
it is disabling perfectly but when the page gets refreshed again it comes
to enable position
so, I need a code even when the refreshing the page also my button is in disable position.
Thanks and Regards,
Srinivas yadav.
Pls help.
when I disable the button using the code
document.getElementById("mybutton").disable=true;
it is disabling perfectly but when the page gets refreshed again it comes
to enable position
so, I need a code even when the refreshing the page also my button is in disable position.
Thanks and Regards,
Srinivas yadav.
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.
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.
<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 1:33 pm.
I don't accept change. I don't deserve to live.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
Happiness corrupts people.
Failing to value the lives of others cheapens your own.
•
•
Join Date: Sep 2007
Posts: 12
Reputation:
Rep Power: 2
Solved Threads: 0
•
•
•
•
Hi Experts here,
Pls help.
when I disable the button using the code
document.getElementById("mybutton").disable=true;
it is disabling perfectly but when the page gets refreshed again it comes
to enable position
so, I need a code even when the refreshing the page also my button is in disable position.
Thanks and Regards,
Srinivas yadav.
you have to do like this...
because you have made the input button after the head tag you can not use the script in the head so you have to write the code after the input button , another problem you had you have to use disabled instead of disable
<html>
<head><head>
<body>
<input type="button" name="mybutton" value="mybutton">
<script language="javascruipt>
document.getElementById("mybutton").disabled=true;
</script>
</body>
</html>
best REgards Pedram
Pedramphp@gmail.com
•
•
Join Date: Jul 2006
Location: Deptford, London
Posts: 971
Reputation:
Rep Power: 5
Solved Threads: 48
•
•
•
•
Originally Posted by pedramphp
because you have made the input button after the head tag you can not use the script in the head so you have to write the code after the input button , another problem you had you have to use disabled instead of disable
Or use the body onload handler as sos suggested.. It makes for a more manageable project if you use onload to call one onload function that does all one-time-only functions, rather than putting bits of script inbetween html elements..
To srinivaskota, if you have some condition that must be met to enable the button; and the condition is usually not yet met when the page is first accessed ( or refreshed ), i.e. the button should only become enabled as the result of some javascript code; set the button as disabled in the HTML, i.e.
<button disabled="true" >Button Text</button>
Last edited by MattEvans : Sep 9th, 2007 at 7:20 pm.
Plato forgot the nullahedron..
![]() |
•
•
•
•
•
•
•
•
DaniWeb JavaScript / DHTML / AJAX Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- How to disable back button and backspace using Javascript..? (JavaScript / DHTML / AJAX)
- How to disable Back button of IE when executing welcome.aspx page? (ASP.NET)
- Problem passing value from radio button to second page. (PHP)
- Disable the Shut Down Button on the Welcome Screen (Windows tips 'n' tweaks)
Other Threads in the JavaScript / DHTML / AJAX Forum
- Previous Thread: AJAX -- should not be too difficult
- Next Thread: How to stop the scroll position when webpage gets refreshed?



Hybrid Mode