CPK_2011
CPK_2011

Reputation: 1150

How to set value for hidden variable in jquery

I am trying to set value 1 for hidden field while making checkboxes as false to not fire the CheckedChanged event.

$('#<%=FindControl("hdfValidateCheck").ClientID %>').val("1");
$get('<%= FindControl("chkUK").ClientID %>').checked = false;
$get('<%= FindControl("chkUS").ClientID %>').checked = false;
$('#<%=FindControl("hdfValidateCheck").ClientID %>').val("0");

But here hidden fields are not set properly and the following code executes completely

protected void chkUS_CheckedChanged(object sender, EventArgs e)
{
    if (chkUS.Checked)
    {
        if (hdfValidateCheck.Value == "0")
        {
            radWindowManager.RadConfirm("Are you sure you want to check?", "confirm" + this.ClientID, 300, 100, null, "");
        }
    }
}

I want this line $('#<%=FindControl("hdfValidateCheck").ClientID %>').val("1"); to be corrected and even I want to shift the chkUS_CheckedChanged event from Server side to Client side.

Upvotes: 1

Views: 91

Answers (1)

rinoy
rinoy

Reputation: 571

Please check whether html object is loaded using developer tools. Then you can work on the selector part and make modifications accordingly.

The below selector will load an object ends with id 'hdfValidateCheck'.

 $("[id$='hdfValidateCheck']")

The below selector will load an object which contains id 'hdfValidateCheck'.

 $("[id*='hdfValidateCheck']")

Then the next step is to define an event on client side with this object.

$("[id$='hdfValidateCheck']").change(function() {
 if($(this).is(":checked")) {

        }
});

Upvotes: 1

Related Questions