0

I have a table showing records from database. There is a dropdown for selecting a particular user in each row. On change, it should show the corresponding values of the new user.

When I'm selecting a particular user from the dropdown, it should match the col1 and col2 value with the user selected and return col3 value. What I want is to get the col1 and col2 value of that particular row. How can I do it ? Please help me.

5
  • 3
    Could you please post your code, or a link to a jsFiddle? Commented Aug 27, 2012 at 6:14
  • Rather than querying the DOM to extract data, have you considered returning the data from the server in an alternate form (eg. JSON)? Trying to extract tabular data out of a table sounds like bad design to me. Commented Aug 27, 2012 at 6:17
  • Have you tried using .rows and .cells properties? Commented Aug 27, 2012 at 6:45
  • sorry guys. I cant post my codes here. Commented Aug 27, 2012 at 7:59
  • thanks for replying.. i'm trying using .rows but how to know which row's dropdown is being changed, so that the corresponding column values will be fetched Commented Aug 27, 2012 at 8:03

1 Answer 1

1

You want to use live('click', function(). This will apply on dynamically created elements.

For example, you may try something like;

$('#your_table_id .some_class_in_a_row_to_click').live('click', function(){
    $(this).siblings().each(function(){
      var column = $(this).find('.some_class_for_column_with_data');
      var data = column.text();
      alert(data);
    });
});

You may apply this on a table having some columns. Clicking on some column with class some_class_in_a_row_to_click will alert text on another column in that row having class some_class_for_column_with_data

Sign up to request clarification or add additional context in comments.

1 Comment

this would work if i was using onclick() on cells. but i want this functionality in onchange() function.. could u help me..

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.