1

I try to select an element, disable it and enable it again using this code:

function change(level) {
    var node = ["ultraSuperPoint", "extraSuperPoint", "superPoint", "Point"];
    if (level <= 4 && level > 0) {
         for (var i = 0; i < 4; i++) {
            if (i < level) {
                $("#" + node[i]).prop("disabled", false); //not work
            } else {
                $("#" + node[i]).prop("disabled", true); //not work
            }
        }
    }
}

it's running correctly but this line is not working. I already tried jQuery prop,removeAttr,attr,removeProp-method but still not working.

this is my html

<select disabled class="form-control convertSinhalaIskolaPotha" name="ultraSuperPoint" id="ultraSuperPoint"  >
                                <option value="0">-N/A-</option>
                                <option value="1">MEMBER</option>
                                <option value="2">ASSOCIATE MEMBER</option>
                                <option value="3">NON MEMBER</option>
                                <option value="4">MEMBER SOCIETY</option>
                                <option value="5">SOCIETY</option>
                                <option value="6">COMPANY</option>
                            </select>

all select element like this,deffarent id and name only

***i know this is duplicate but i already try that solutions.

1 Answers1

-1

you can use like that $("#test").prop("disabled", "false");

your code will be like that

function change(level) {
    var node = ["ultraSuperPoint", "extraSuperPoint", "superPoint", "Point"];
    if (level <= 4 && level > 0) {
        for (var i = 0; i < 4; i++) {
            if (i < level) {
                $("#" + node[i]).prop("disabled", "false"); 
            } else {
                $("#" + node[i]).prop("disabled", "true"); 
            }
        }
    }
}
Bhavdip
  • 19
  • 1
  • 8