gpt4 book ai didi

javascript - jQuery 删除中继器中的输入值

转载 作者:太空宇宙 更新时间:2023-11-04 16:11:28 25 4
gpt4 key购买 nike

我有一个中继器:

<asp:Repeater ID = "rpQuestion8" runat = "server" >
<ItemTemplate>
<tr>
<td>
<asp:DropDownList ID = "ddCounty" runat = "server" AutoPostBack="true" />
<input type = "hidden" id = "hidSurveyCustomerAreaID" runat = "server" value = '<%#showData(Container.DataItem, "SurveyCustomerAreaID")%>' />
</td>
<td>
<asp:radiobutton id = "radStillStandHuntMethod" text = "Still/Stand" runat = "server" GroupName = "Question8HuntMethod"/>
&nbsp;&nbsp;&nbsp;
<asp:radiobutton id = "radDogHuntMethod" text = "Dog" runat = "server" GroupName = "Question8HuntMethod"/>
</td>
<td>
<asp:TextBox ID = "txtDaysHunted" runat = "server" Width = "50" text = '<%#showData(Container.DataItem, "DaysHunted")%>'/>
<asp:CompareValidator ID = "cvNumDays" runat = "server" ControlToValidate = "txtDaysHunted" Operator = "DataTypeCheck" Type = "Integer" Text = "*" ErrorMessage = "Please enter a whole number for Days Hunted." />
</td>
<td>
<asp:radiobutton id = "radYesUnprocessedFood" text = "Yes" runat = "server" GroupName = "Question8UnprocessedFood" />
&nbsp;&nbsp;&nbsp;
<asp:radiobutton id = "radNoUnprocessedFood" text = "No" runat = "server" GroupName = "Question8UnprocessedFood" />
</td>
<td>
<asp:TextBox ID = "txtNumSeen" runat = "server" Width = "50" text = '<%#showData(Container.DataItem, "NumberSeen")%>' />
<asp:CompareValidator ID = "cvBearsSeen" runat = "server" ControlToValidate = "txtNumSeen" Operator = "DataTypeCheck" Type = "Integer" Text = "*" ErrorMessage = "Please enter a whole number for Number of Bears Seen." />
</td>
<td>
<asp:radiobutton id = "radYes" text = "Yes" runat = "server" GroupName = "Question8Harvest" />
&nbsp;&nbsp;&nbsp;
<asp:radiobutton id = "radNo" text = "No" runat = "server" GroupName = "Question8Harvest" />
</td>
</tr>
</ItemTemplate>
</asp:Repeater>

jQuery:

 <script src="../../../Javascript/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
function ddCountyChange(sender) {
if (sender.value === "") {
$(sender).parent().siblings().find("input").attr("disabled", "disabled");
$(sender).parent().siblings().find("input").val('');
$(sender).parent().siblings().find("input").prop('checked', false);
$(sender).parent().siblings().find("label").css("color", "#cccccc");
$(sender).parent().siblings().find("input").val('');
} else {
$(sender).parent().siblings().find("input").removeAttr('disabled');
$(sender).parent().siblings().find("label").css("color", "#000000");
}
}
</script>

我希望能够删除隐藏输入的值 (id = "hidSurveyCustomerAreaID")。上面的 jQuery 代码对中继器中的所有输入执行此操作,除了 (id = "hidSurveyCustomerAreaID")。

最佳答案

我将其添加到 JQuery 代码中:

$(sender).parent().find("input").val('');

这将访问下拉列表所在的同一 td 内的输入。

function ddCountyChange(sender) {
if (sender.value === "") {
$(sender).parent().siblings().find("input").attr("disabled", "disabled");
$(sender).parent().siblings().find("input").val('');
$(sender).parent().find("input").val('');
$(sender).parent().siblings().find("input").prop('checked', false);
$(sender).parent().siblings().find("label").css("color", "#cccccc");
} else {
$(sender).parent().siblings().find("input").removeAttr('disabled');
$(sender).parent().siblings().find("label").css("color", "#000000");
}
}

关于javascript - jQuery 删除中继器中的输入值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41447873/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com