Topic: Enabling/Disabling select element using jQuery not working with update

Jordan Mack pro asked 5 years ago


Expected behavior: Select box becomes enabled when there is a change to a different select box

Actual behavior: Select box remains disabled

**Resources (screenshots, code snippets etc.)**

When changing to the pro version, some functionality has been lossed. Upon changing a select box, I had a code that enabled a different select box depending on if a value had been selected in the first box. I have since lost this functionality and am unable to debug this problem. Here is my code:

function enableVend(){
  if ("#pro option:selected") {
    console.log('should enable');
    debugger;
    $("#vendorid").prop('disabled', false);
    debugger;
  } else {
    $("#vendorid").prop('disabled', true);
  }
}

It is everything is working as it should other than:

$("#vendorid").prop('disabled', false);

All help is very appreciated.

Also my MDB version is actually 4.8.1


ltanase pro answered 3 years ago


I am using MDB5 Version Pro 3.8.1 and I need to dynamically disable and enable a select element.

Is there an easy way to do it?

I have tried to remove the disabled and readonly attribute from the input element inside select-wrapper div, but beside the gray color being removed, you canot change the selection.

Many thanks!


ltanase pro commented 3 years ago

I solved it. I realized that you need removing the disabled attribute from the select element itself, too.


Marcin Luczak staff commented 3 years ago

Hi @ltanase, good to hear that! :)

Keep coding, Marcin


Adam Jakubowski staff answered 5 years ago


Hi,

please, create a snippet showing your problem here: https://mdbootstrap.com/snippets/. I'll try to help you.

Best,

Adam



Please insert min. 20 characters.

FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Answered

Specification of the issue

  • ForumUser: Pro
  • Premium support: No
  • Technology: MDB jQuery
  • MDB Version: 4.8.0
  • Device: Dell XPS 15 9550
  • Browser: Chrom
  • OS: Windows 10
  • Provided sample code: No
  • Provided link: No