Topic: change select to disabled using a checkbox

kaz priority asked 4 years ago


Hi

I hope you are well.

I have a checkbox which when checked should make the select field disabled but for some reason, I can't get it working. It works fine to disable an input type of text but not a select.

I have created a snippet so speed things up:https://mdbootstrap.com/snippets/jquery/kazosman/2186925

Can you please advise?

Many thanksKaz


kaz priority answered 4 years ago


Hi Tomek

I hope you are well.

Thank you for your help.

One last thing please - if the checkbox is already checked when the page loads is it possible to have the select disabled at that time?

Thanks Kaz


Tomek Makowski staff commented 4 years ago

Of course do the same thing but on window.onload event


kaz priority answered 4 years ago


Hi

I hope you are well.

I have expanded the example snippet as I need to disable the select when the checkbox is checked and enable the select when the checkbox is not checked.The not checked part doesn't work - can you please take a look:

https://mdbootstrap.com/snippets/jquery/tomasz-makowski/2192428?view=project#js-tab-view

Also if the checkbox loads in a checked state - is it possible to have the select disabled at the page load time?

ThanksKaz


Tomek Makowski staff commented 4 years ago

Hi

Check this out

https://mdbootstrap.com/snippets/jquery/tomasz-makowski/2192428?view=project#js-tab-view

Regards


kaz priority answered 4 years ago


Hi Tomek

I hope you are well.

Thank you very much for your answer.

Kind regards Kaz


Tomek Makowski staff answered 4 years ago


Hi

All you have to do is just reinitialize material select after changes. Then script will render it with new value like disabled="true" .

https://mdbootstrap.com/snippets/jquery/tomasz-makowski/2192428?view=project#js-tab-view

Regards



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: Priority
  • Premium support: Yes
  • Technology: MDB jQuery
  • MDB Version: 4.19.0
  • Device: n/a
  • Browser: firefox and chrome
  • OS: Ubuntu
  • Provided sample code: No
  • Provided link: Yes