How do I activate or deactivate the button according to the value of the variabl...
source link: https://www.codesd.com/item/how-do-i-activate-or-deactivate-the-button-according-to-the-value-of-the-variable.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How do I activate or deactivate the button according to the value of the variable?
I use pure javascript. I have this row in my asp page:
<input type="button" value="..." id="ffcolorswtach" style="width: 20px; height: 19px; position: relative; left: 15px; top: 0px; color: #ff0000; background-color: #d8d5d5;" onclick="PickColor(1, false, false)" role="button" />
Also I have javascript variable in my client page that contains true/false values:
var isColorSelected
When isColorSelected is false i want to enable input element above if false I want to disable it.Any idea how can I implement it?
Try something like the following:
if(isColorSelected != true)
document.getElementById("ffcolorswtach").disabled = true;
else
document.getElementById("ffcolorswtach").disabled = false;
This is finding that element within the DOM and using the built in browser capability to disable the element for you.
Related Articles
How do I activate or deactivate the status item in the menu bar with a check box?
How to activate or deactivate any button in angle 2 according to the mandatory and optional field
Flash Actionscript 3 Activate or deactivate the menu buttons
How to hide, activate, modify WPF graphical interfaces according to different types of users?
Deactivate radio button according to date
How to improve var_dump to display the variable name and set the value of the variable to & lt; Pre & gt;
Count how many digits and letters in the variable using PHP
Activate or deactivate the foundation connection button
Activate or deactivate the button according to another button
Activate and deactivate the text box by pressing the
How do I activate javascript in the client window if it disables it in its browser?
How do I activate 'openssl' in the UwAmp CLI?
How do I activate and deactivate a component?
How to programmatically activate and deactivate GPS in Ionic Framework or Cordova
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK