Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074625
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:09:26+00:00 2026-05-16T21:09:26+00:00

I have a table set out like: <table id=myTable> <thead> <tr> <td><input type=checkbox id=selectall

  • 0

I have a table set out like:

<table id="myTable">
  <thead>
    <tr>
      <td><input type="checkbox" id="selectall" /></td>
      <td>Column 1</td>
      <td>Column 2</td>
      <td>Column 3</td>
      <td>Column 4</td>
      <td>Column 5</td>
    </tr>
  </thead>
  <tbody>
  </tbody>
</table>

Then, the javascript:

var myTable = jQuery('#myTable').dataTable({
    /* options */
});

// Ajax request to populate:
jQuery.get('script.php', function(data){
    eval("rows="+data);
    for(var i=0;i<rows.length;i++){
        myTable.fnAddData([
          "<input type=\"checkbox\" id=\""+rows[i].uniqueID+"\" />",
          rows[i].col1Txt,
          rows[i].col2Txt,
          rows[i].col3Txt,
          rows[i].col4Txt,
          rows[i].col5Txt ]);
    }
});

Now, I am having trouble with updating the table based on which checkboxes are selected:

I am trying to update the 5th cell in each row that is checked. I am using a combination of fnUpdate and fnGetPosition (http://www.datatables.net/api).

fnGetPosition expects the td or tr element, so I thought I’d just grab the parent td of the checkboxes:

var checkBoxes = jQuery('td > input:checked', myTable);
for(var i=0;i<checkBoxes.length;i++){
    var parentTD = jQuery('#'+checkBoxes[i].id).parent(); //seems wrong?
    var pos = myTable.fnGetPosition(parentTD);
    //alert(pos[0]);
    myTable.fnUpdate('Updated text', pos[0], 5);
}

But I must be doing parentTD wrong since pos never seems to hold a value.

Any ideas?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:09:27+00:00Added an answer on May 16, 2026 at 9:09 pm

    you can use the each function to iterate over a jQuery object, its easier than using the for loop.

    Also, I think that you can optomise your selector to get you the td elements instead of geting the checked inputs.

    It will be a lot more performant as it should remove 2 selectors in every operation.
    I haven’t tried it but something like this should work

    var checkBoxes = jQuery('td:has(input:checked):not(#selectall)', myTable);
    checkboxes.each(function(){
        var pos = myTable.fnGetPosition($(this)); // Im not familiar with the plugin so the extra $() might be overkill
        alert(pos) // maybe run this alert again, check if you get back an object/value? use firebug to debug and see its value?
        myTable.fnUpdate('Updated text', pos[0], 5);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table where one of the left column shrinks when I set
I have a pretty standard table set-up in a current application using the .NET
I have one table that saves comments for a varied set of content types.
I have a table with say 1640 items. I set bindingSource.Filter = some filter
I have a set of records in my MS SQL table. With Date as
I have a set of tables in Oracle and I would like to identify
We have an Access DB which has a set of local tables and input
I have table with 50 entries (users with such details like Name Surname Location
I have table inside a div tab. The table has 40 rows in it
I have table rows of data in html being filled from a CGI application.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.