javascript - How do I get all values of checkbox those are checked using ajax/jQuery in asp.net -


when click select working days / hours checkbox list of days displayed. example if click sunday checkbox check box value entered in checkbox should call javascript function. in case not click checkbox value display should null.

demo link html

$(document).ready(function () {              $("input#btndocbusinesshours").click(function () { savedocbusinesshours(null) });         }); 

call ajax function

function callajax(jparms) {             $.ajax({                 type: "post",                 url: jparms.url,                 data: jparms.data,                 contenttype: "application/json; charset=utf-8",                 datatype: "json",                 success: function (response) {                     if (jparms.action == "savedocbusinesshours")                         savedocbusinesshours(response.d)                  },                 failure: function (response) { response.d; }             });         } 

save ajax function

 function savedocbusinesshours(response) {             var values = $('input[type="checkbox"].single:checked').map(function () {                 return $(this).val();             }).toarray();               if (response == null) {                 callajax({                     url: pageurl + '/savedocbusinesshours',                     data: '{"doctorid": "' + $("#<%=hdndoctorid.clientid %>").val() + '","workingdaysid" : "' + $("#<%=hdnbusiness.clientid %>").val() + '","sunday" : "' + $("#<%=chksun.clientid %>").val() + '","monday" : "' + $("#<%=chkmon.clientid %>").val() + '","thuesday" : "' + $("#<%=chktue.clientid %>").val() + '"}',                     action: "savedocbusinesshours"                 });                 window.location.reload();             }             else {                 loading(false);                 if (response.ajxcontactid != null) {                     $('#<%=hdnbusiness.clientid%>').val(response.ajxcontactid);                 }                 msg(true, response.message);             }          } 

webmethod:

[webmethod]     public static userajax savedocbusinesshours(string doctorid, string workingdaysid, string sunday, string monday, string thuesday)     {         userajax ouserajax = new userajax();         return ouserajax;     } 


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -