Need help for chekboes

Hello, I need some help regarding on the checkboxes, How do i get the emp_actno if the checkbox is selected,
for example this data: 01,02,04 are selected and i want to get this 101,102 and 104.


  <tr>
   <input type="checkbox" value="01" name="emp">
   <td>john</td>
   <td>manager</td>
   <td>101</td>
  </tr>  

 <tr>
   <input type="checkbox" value="02" name="emp">
   <td>mathias</td>
   <td>SEO</td>
   <td>102</td>
  </tr>  

 <tr>
   <input type="checkbox" value="03" name="emp">
   <td>jack</td>
   <td>supervisor</td>
   <td>103</td>
  </tr>  

 <tr>
   <input type="checkbox" value="04" name="emp">
   <td>Gibson</td>
   <td>Team leader</td>
   <td>104</td>
  </tr>  



Thank you in advance

First of all, why don’t you put the value you want to get in the value of the checkbox?
Second, if you have to send the form data to a PHP script, then give the checkboxes the name emp . I don’t know if it makes a difference for javascript, but in PHP you will be able to access the checked box values in the $_POST[‘emp’] array.

Hi guido2004,Thank you for the reply.

First of all, why don’t you put the value you want to get in the value of the checkbox?

I have other function that used to get the value of the checkbox

Second, if you have to send the form data to a PHP script, then give the checkboxes the name emp

can you please show me example of this,i have no idea for this and i never yet tried to use name in array.

Thank you in advance.

Okay i got it now.thank you.

Hi jemz,

You can do it like this:

<!DOCTYPE HTML>
<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title>nextAll()</title>
    <script src="http://code.jquery.com/jquery-latest.js"></script>
  </head>
  <body>
    <table>
      <tr>
        <td><input type="checkbox" value="01" name="emp" checked></td>
        <td>john</td>
        <td>manager</td>
        <td>101</td>
      </tr>

      <tr>
        <td><input type="checkbox" value="02" name="emp" checked></td>
        <td>mathias</td>
        <td>SEO</td>
        <td>102</td>
      </tr>

      <tr>
        <td><input type="checkbox" value="03" name="emp"></td>
        <td>jack</td>
        <td>supervisor</td>
        <td>103</td>
      </tr>

      <tr>
        <td><input type="checkbox" value="04" name="emp" checked></td>
        <td>Gibson</td>
        <td>Team leader</td>
        <td>104</td>
      </tr>
    </table>

    <script>
      $('input:checked').each(function() {
        console.log($(this).parent().nextAll().eq(2).text());
      });
    </script>
  </body>
</html>

Hi pullo ,is this will get the value of td if the checkbox is checked?

No, but this will:

$('input[type="checkbox"]').change(function(){
  $('input:checked').each(function() {
    console.log($(this).parent().nextAll().eq(2).text());
  });
});

At least I hope this is what you mean.

Hi pullo, it’s working thank you so much.

No problem jemz,
Thanks for taking the time to report back :slight_smile: