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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to dynamically disable a button 1

Status
Not open for further replies.

Ovatvvon

Programmer
Joined
Feb 1, 2001
Messages
1,514
Location
US
Hello all,

I am seeming to not be able to remember how to disable a button. Can someone enlighten me?


-Ovatvvon :-Q
 
well, depending on how you call the code you want to call, the very basic concept is:

Code:
objectElement.disabled = disabled;



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
I made a mistake...

Code:
objectElement.disabled = true;

Code:
<input type="submit" onclick="this.disabled = true;" />



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Ok, this is weird. I am doing something different - obviously, but not sure what it is. Either way, it works now. *Hate days like this*

-Ovatvvon :-Q
 
you were putting that in your style attribute. style attributes can't do javascript.

onclick is an event handler. your browser knows to call the javascript inside the quotes when that action is performed on the element.



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
yes, on the one I provided before, but, oddly enough I had tried putting it in an onClick (and also onChange) event, and it didn't work either. So, I obviously had something else wrong as well. Either way, it works now. Thanks for your help!

-Ovatvvon :-Q
 
actually, LFI hit the nail on the head in the HTML / CSS forum. You were trying to access a property that didn't exist, "enabled". The correct property is "disabled".



*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
Thanks for the endorsement, cLFlaVA!

Your SW,

Dave


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
O Time, Strength, Cash, and Patience! [infinity]
 
star.gif




*cLFlaVA
----------------------------
[tt]I already made like infinity of those at scout camp...[/tt]
[URL unfurl="true"]http://www.coryarthus.com/[/url]
[banghead]
 
For the second time today...

[blush]


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

Part and Inventory Search

Sponsor

Back
Top