I try to set readonly fields for specific lines where "sth" is set in select box
the code is executed when the page is loaded / at the start of the form
i tried:
.js file
$(document).ready(function () {
$(".ecp-row").each(function () {
var start = $(this).find(".start");
var end = $(this).find(".end");
var hours = $(this).find(".gethours");
var selectboxlist = $(this).find(".selectboxlist").eq(0).val();
if (selectboxlist === "sth") {
alert("test"); // it works
start.readOnly = true; // it doesnt work
end.readOnly = true; // it doesnt work
hours.readOnly = true; // it doesnt work
}
});
});
html
@for (int nr_rows = 0; nr_rows < @ViewBag.sthelse; nr_rows++)
{
<tr class="ecp-row">
<td id="td3" >@Html.TextBoxFor(m => m.Model7[nr_rows].a, new { @class = "start"})</td>
<td id="td4" >@Html.TextBoxFor(m => m.Model7[nr_rows].b, new { @class = "end" })</td>
<td id="td5" >@Html.TextBoxFor(m => m.Model7[nr_rows].c, new { @class = "gethours" })</td>
<td id="td6" >@Html.DropDownListFor(m => m.Model7[nr_rows].sth, new SelectList(Enum.GetValues(typeof(sth))), " ", new { @class = "selectboxlist" })</td>
</tr>
}