Skip to content
Advertisement

How to set the input disable with condition?

I have a problem to set the input box become disable with condition. My condition is if the value is 0, then the input box will become disable. I have add readonly in the html box, but it also can’t work.

Below is what I am tried the coding, Hope anyone can guide me to check which part I am getting wrong.:

JavaScript

Actually I want the output like below the picture:

Output 1

Advertisement

Answer

Your code contains many errors.

And your question is not clear.

If you want to make input boxes as readonly when you select ‘New Category’ ( value is 0), and otherwise make input boxes editable, you need to use javascript or jQuery.

JavaScript

jQuery code

JavaScript
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement