mardi 22 novembre 2016

jquery checked and unchecked events

I have a problem here with the following code

$('.paron').change(function() {
   if($(this).is(":checked")) {
          var moduleid = <?php echo $moduleid; ?>;
                var studentid = $(this).attr('id');
                var weeknum = <?php echo $weeknum; ?>;

                undisableTxt(studentid);

             }
       });

So I take the id of a certain tr which has an input and i send it to a function. All good till now. But this is happening when the user check the input [checkbox] when he UNCHECK, how can i have the id to send it to another function???

I've tried the following but no luck

   $('.paron').change(function() {
if($(this).is(":checked")) {
     var moduleid = <?php echo $moduleid; ?>;
     var studentid = $(this).attr('id');
     var weeknum = <?php echo $weeknum; ?>;

             undisableTxt(studentid);

      } else {
        disableTxt(studentid); //error for undefined variable student id.
      }
  });

So i get an error for undefined studentid. FYI each row has another id.




Aucun commentaire:

Enregistrer un commentaire