I'm unable to enable/disable the FeeOtherServiceRequested input control on selection change of select control FeeServiceRequested. Only first row is working.
I have this table in .net MVC cshtml page
<tbody>
@foreach (DataRow row in Model.Tables["PM_Fee"].Rows)
{
<tr>
<td>
<div class="editDelInputFee FeeServiceRequestedText">
@row["FeeDescription"]
</div>
<div class="saveCanInputFee FeeServiceRequestedSelectFee" style="display:none">
<select class="form-control form-control-sm " style="font-size:8pt;" id="FeeServiceRequested" onchange="EnableOtherTextbox_Fee(this);">
@foreach (DataRow row0 in Model.Tables["PM_Fee_ServiceRequested"].Rows)
{
<option value="@row0["ServiceRequested"]">@row0["ServiceRequested"]</option>
}
</select>
</div>
</td>
<td>
<div class="editDelInputFee FeeOtherServiceRequestedText">
@row["FeeOtherDescription"]
</div>
<div class="saveCanInputFee FeeOtherServiceRequestedInputFee" style="display:none">
<input type="text" class="form-control form-control-sm " style="font-size:8pt;" id="FeeOtherServiceRequested">
</div>
</td>
</tr>
}
</tbody>
and this javascript function
function EnableOtherTextbox_Fee(sel) {
var tableRow = $(sel).closest('tr');
var FeeOtherServiceRequested = tableRow.find("input[id*='FeeOtherServiceRequested']");
var inputs = document.getElementById('FeeOtherServiceRequested');
if (sel.value == "Other (specify)") {
inputs.disabled = false;
}
else {
inputs.disabled = true; inputs.value = '';
}
}
