【发布时间】:2017-07-14 11:28:39
【问题描述】:
我创建了一个局部视图并在同一页面中使用了n 次。局部视图放置在手风琴内(div),当单击复选框时,应禁用文本框。
当我渲染使用局部视图 5 次的页面并单击复选框时,文本框仅在第一个局部视图中被禁用。相同的功能在其他任何一个中都不起作用。
当我将调试器放置在它命中的所有局部视图中时,文本框并没有被禁用。这仅在第一个部分视图中有效,但在其余部分中失败。
请找到下面的代码..
<table>
<tr>
<th>Select Recurrance:</th>
<th>Start DateTime:</th>
<th>End DateTime:</th>
</tr>
<tr>
<td>
<div style="margin-top: -0.0em;">
<select id="Recurrances" onchange="SubmitRecurrance(this)">
<option selected="selected" value="1">Run Continuosly</option>
<option value="2">Run on Schedule</option>
</select>
<br />
@Html.ValidationMessageFor(model => model.Recurrance)
</div>
</td>
<td>
<div style="margin-top: -0.0em;">
@Html.TextBoxFor(model => model.StartDateTime, new { @class = "form-control date-picker", @placeholder = "Start Date&Time", id = "starttime", onkeyup = "FormDirty();" })
<br />
@Html.ValidationMessageFor(model => model.StartDateTime)
</div>
</td>
<td>
<div style="margin-top: -0.0em;">
@Html.TextBoxFor(model => model.EndDateTime, new { @class = "form-control date-picker", @placeholder = "End Date&Time", id = "endtime", onkeyup = "FormDirty();" })
<br />
@Html.ValidationMessageFor(model => model.StartDateTime)
</div>
</td>
</tr>
<tr>
<td id="divnoenddate">
<div>
<span> No End Date</span>@Html.CheckBox("NoEndDate", false, new { id = "noenddate", onchange = "javascript:ChangeCheckBox()" })
<br />
</div>
</td>
<td id="recureveryoption">
<span style="font-weight:bold;">Recur Every:</span> <div>
<select id="RecurEvery">
<option selected="selected" value="1">Daily</option>
<option value="2">Weekly</option>
<option value="3">Monthly</option>
<option value="4">Yearly</option>
</select>
</div>
</td>
<td>
<div>
<input type="submit" value="Save" style=" width: 8em;height: 2em;text-align: center;padding-top: 6px;background: #0082BF;font-size: 1em; color: #0082BF; cursor:pointer; color:white;font-size: 1em; padding-left:6px; padding-right:6px;padding-bottom:6px;" onclick="SubmitChanges()" />
</div>
</td>
</tr>
</table>
function ChangeCheckBox()
{
if (document.getElementById("Recurrances").value != 1)
{
debugger;
if (document.getElementById('noenddate').checked == true)
{
document.getElementById("endtime").disabled = true;
}
else
{
document.getElementById("endtime").disabled = false;
}
}
}
我将上述部分观点称为:
<div>
@Html.Partial("~/Views/Settings/ScedularControl.cshtml")
</div>
【问题讨论】:
-
你能提供更多的细节,代码或小提琴等...
-
你能给我们看一下带有复选框的 HTML 和附带的 Javascript 吗?
标签: javascript c# jquery asp.net-mvc