How can I disable an <option> in a <select> based on its value in JavaScript?

android disable app without uninstall
how to delete preinstalled apps on android
how to delete apps on samsung
how to delete apps on android that came with phone
what apps can i delete on android
how do i uninstall built in apps on android?
how to uninstall apps on android that won't uninstall
android system apps safe to disable

I have a <select> with a number of <option>s. Each has a unique value. I need to disable an <option> with a given defined value (not innerhtml).

Anyone have an idea how?

Pure Javascript

With pure Javascript, you'd have to cycle through each option, and check the value of it individually.

// Get all options within <select id='foo'>...</select>
var op = document.getElementById("foo").getElementsByTagName("option");
for (var i = 0; i < op.length; i++) {
  // lowercase comparison for case-insensitivity
  (op[i].value.toLowerCase() == "stackoverflow") 
    ? op[i].disabled = true 
    : op[i].disabled = false ;
}

Without enabling non-targeted elements:

// Get all options within <select id='foo'>...</select>
var op = document.getElementById("foo").getElementsByTagName("option");
for (var i = 0; i < op.length; i++) {
  // lowercase comparison for case-insensitivity
  if (op[i].value.toLowerCase() == "stackoverflow") {
    op[i].disabled = true;
  }
}
jQuery

With jQuery you can do this with a single line:

$("option[value='stackoverflow']")
  .attr("disabled", "disabled")
  .siblings().removeAttr("disabled");

Without enabling non-targeted elements:

$("option[value='stackoverflow']").attr("disabled", "disabled");

​ Note that this is not case insensitive. "StackOverflow" will not equal "stackoverflow". To get a case-insensitive match, you'd have to cycle through each, converting the value to a lower case, and then check against that:

$("option").each(function(){
  if ($(this).val().toLowerCase() == "stackoverflow") {
    $(this).attr("disabled", "disabled").siblings().removeAttr("disabled");
  }
});

Without enabling non-targeted elements:

$("option").each(function(){
  if ($(this).val().toLowerCase() == "stackoverflow") {
    $(this).attr("disabled", "disabled");
  }
});

How to Disable Bloatware Apps on an Android Phone or Tablet, How do I disable an app that Cannot be disabled? How to disable the lock screen in the Pro edition of Windows 10 If you're running a Pro edition (including Enterprise and Education) of Windows 10, you can use the Group Policy editor to remove

Set an id to the option then use get element by id and disable it when x value has been selected..

example

<body>
      <select class="pull-right text-muted small" 
                 name="driveCapacity" id=driveCapacity onchange="checkRPM()">
      <option value="4000.0" id="4000">4TB</option>
      <option value="900.0" id="900">900GB</option>
      <option value="300.0" id ="300">300GB</option>
    </select>
    </body>
<script>
var perfType = document.getElementById("driveRPM").value;
if(perfType == "7200"){         
        document.getElementById("driveCapacity").value = "4000.0";
        document.getElementById("4000").disabled = false;           
    }else{          
        document.getElementById("4000").disabled = true;            
    }    
</script>

Which Google apps can be deleted or disabled without harm to the , list, so it's a good way to clean your list up. How do I disable my antivirus program in Windows? Updated: 01/24/2018 by Computer Hope It should be noted that the instructions in this document are for temporarily disabling an antivirus program, not uninstalling an antivirus .

var vals = new Array( 2, 3, 5, 8 );
select_disable_options('add_reklamaciq_reason',vals);
select_disable_options('add_reklamaciq_reason');

function select_disable_options(selectid,vals){
  var selected = false ;
  $('#'+selectid+' option').removeAttr('selected');
  $('#'+selectid+' option').each(function(i,elem){
       var elid = parseInt($(elem).attr('value'));
       if(vals){
           if(vals.indexOf(elid) != -1){
               $(elem).removeAttr('disabled');
               if(selected == false){
                   $(elem).attr('selected','selected');
                   selected = true ; 
               }
           }else{
               $(elem).attr('disabled','disabled'); 
           }
       }else{
            $(elem).removeAttr('disabled');
       }
  });   
}

Here with JQ .. if anybody search it

Is removing an app any different from disabling an app?, consume more memory. there is no harmful effect on your device after removing this. The simple way to disable sign-in so that you can just dive right in and start using your PC. Here’s how you do it. Right-click the Start button and select the Run option. Type “netplwiz” and hit enter. This will open the User Accounts window. Choose the one that you would like to skip the whole login and password option for.

I would like to give you also the idea to disable an <option> with a given defined value (not innerhtml). I recommend to it with jQuery to get the simplest way. See my sample below.

HTML

Status:  
<div id="option">
   <select class="status">
      <option value="hand" selected>Hand</option>
      <option value="simple">Typed</option>
      <option value="printed">Printed</option>
   </select>
</div>

Javascript

The idea here is how to disable Printed option when current Status is Hand

var status = $('#option').find('.status');//to get current the selected value
var op = status.find('option');//to get the elements for disable attribute
(status.val() == 'hand')? op[2].disabled = true: op[2].disabled = false;

You may see how it works here:

https://jsfiddle.net/chetabahana/f7ejxhnk/28/

Delete or disable apps on Android - Android Help, physically removes the app and all connected data from the device. How to Turn Off Windows 10 S Mode. Go to Settings . Then select Update & Security. In the left sidebar, click Activation. Then click “Go to the Store.”. You will see this under the “Switch to Windows 10 Home / Pro” section. Press the “Get” button under the “Switch out of S Mode” section and wait for

For some reason other answers are unnecessarily complex, it's easy to do it in one line in pure JavaScript:

Array.prototype.find.call(selectElement.options, o => o.value === optionValue).disabled = true;

or

selectElement.querySelector('option[value="'+optionValue.replace(/["\\]/g, '\\$&')+'"]').disabled = true;

The performance depends on the number of the options (the more the options, the slower the first one) and whether you can omit the escaping (the replace call) from the second one. Also the first one uses Array.find and arrow functions that are not available in IE11.

How do I temporarily disable my Instagram account?, Delete or disable apps on Android. You can uninstall apps you've installed on your phone. If you remove an app you paid for, you can reinstall it later without  Most computers come with built-in cameras that applications and services can activate on their own if users give the appropriate permissions. If privacy is a concern, you may want to disable the integrated webcam altogether on your computer.

3 Ways to Disable an iPhone, If you temporarily disable your Instagram account, your profile, photos, comments and likes will be hidden until you reactivate it by logging back in. How to Fix a Disabled iPhone, iPad, or iPod. Restore iPhone from backup. The first step you should try is to restore the device from a backup using iTunes . To do that, connect your iOS Use Recovery Mode. If that doesn't work, or if you've never synced your device with iTunes, you need to try

How To Disable System Apps On Android, This wikiHow teaches you how to disable your iPhone. If you have iOS 12 installed on your iPhone, you can use the Screen Time feature to regulate your app  To disable these options, open File Explorer’s options window by clicking the “View” tab at the top of a FIle Explorer window and clicking the “Options” button on the ribbon. Click the “View” tab at the top of the Folder Options window that appears, scroll down in the list of advanced settings,

How do I Uninstall or Disable an Application from my Samsung , Video on how to disable system apps on Android version 4.0 Ice Cream Sandwich and up Duration: 1:28 Posted: Mar 28, 2012

Comments
  • I think the best solution for this is given in another question: stackoverflow.com/questions/31860103/…
  • No, with the value, you would use $("option[value=someval]"). He's looking for the value, not the text inside.
  • Ah, good point, @KyleButt. I've updated my solution. Thank you for pointing that out.
  • Disabling the options with "stackoverflow" doesn’t imply to enable those without "stackoverflow".
  • @Gumbo: Correct. I was trying anticipate future problems, but I can see how my solution would cause more problems, such as if the user had other options disabled by default. I've updated my solution. Thanks for pointing out my error.
  • op[i].disabled = (op[i].value.toLowerCase() == "stackoverflow") ;) +1
  • The questions asks for "value (not innerhtml)" and you test inner text.
  • I formatted the code, but the other hideosities of this function are on you to fix. :P