-1
我想從javascript中的複選框中獲取值,以檢查值是True還是False,如果「False」我想顯示彈出確認「Yes/No?」。如何從javascript複選框獲取值爲校驗值是True還是False?
的javascript
function Confirm() {
var confirm_value = document.createElement("INPUT");
confirm_value.type = "hidden";
confirm_value.name = "confirm_value";
var isChecked = $('#chkSome').is(':checked');
if (isChecked) {
}
else {
if (confirm("Yes/No?")) {
confirm_value.value = "Yes";
} else {
confirm_value.value = "No";
}
document.forms[0].appendChild(confirm_value); ;
}
}
C#(模板列中的GridView)
<asp:TemplateField HeaderText="Some Pcs">
<ItemTemplate>
<asp:CheckBox runat="server" ID="chkSome" Width="20px" AutoPostBack="true" onclick="Confirm();" OnCheckedChanged="chkSome_OnCheckedChanged" />
<asp:Label runat="server" ID="lblQty" Style=" padding-right:2px;" Width="48px" Text='<%# Bind("Quantity") %>'></asp:Label>
<asp:Label runat="server" ID="lblCSQty" Text='<%# Bind("CSQty") %>' Visible="false"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
C#(代碼時檢查變化的背後)
protected void chkSome_OnCheckedChanged(object sender, EventArgs e)
{
CheckBox chk = sender as CheckBox;
GridViewRow rowindex = chk.NamingContainer as GridViewRow;
CheckBox chkSome = (CheckBox)GridView3.Rows[rowindex.RowIndex].FindControl("chkSome");
if (chkSome.Checked)
{
//do something
}
else
{
confirmValue = Request.Form["confirm_value"];
if (confirmValue == "Yes")
{
//do something
}
}
}
微軟JScript運行時錯誤:無法獲取財產「的價值檢查':object是null或undefined。它在點擊chckckbox時顯示此消息。 – SueSaya