dimanche 3 mai 2015

update Html.TextBoxFor "readonly" attribute on and off

I'm srugelling with this, Working on MVC, upon change on Html.TextBoxFor value I want to change a readonly attribute of another Html.TextBoxFor. I tried several ways-using IE it does not work. here some code:

@Html.TextBoxFor(x => x.NumberOfQuestion, new { id = "ExamOptions", onchange = "javascript:ReadOnlyHandle();" })

<script>
    function ReadOnlyHandle() {
        //document.getElementById("NoDiffNum").readOnly = true;
        var startHSelect = document.getElementById("NoDiffNum");
        debugger;
        startHSelect.setAttribute("readonly", "true");
    }
    debugger;
</script>

and the row in a table I would like to change:

<td id="NoDiffNum">@Html.TextBoxFor(model => model.Topics[i].NumberOfNoDifficulltySet)</td>

the readonly attribute did not changed - any help is most welcome!

Aucun commentaire:

Enregistrer un commentaire