Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get value of asp.net CheckBox via jquery(true/false)

Tags:

jquery

asp.net

got the answer syntax error

i want to get value of asp.net check box via jquery , if its selected return true otherwise false. i'm doing this: -

  var ApprovalRequired = $('<%= chkRequired.ClientID %>').is(':checked');
  // also
   var ApprovalRequired = $('<%= chkRequired.ClientID %>').val();

and the checkbox return in html as

  <input id="ctl00_ContentPlaceHolder1_chkRequired" type="checkbox" name="ctl00$ContentPlaceHolder1$chkRequired" checked="checked">

in either way its returning 'false'. Any idea to get true when checked and false on unchecked

like image 547
Siz S Avatar asked May 02 '13 18:05

Siz S


1 Answers

You forgot the # in your selector:

$('#<%= chkRequired.ClientID %>').is(':checked');

That should work

like image 199
tymeJV Avatar answered Oct 02 '22 03:10

tymeJV