I was working on a project which allows the user to update the text in an html table. The only thing is, I need to know which columns of the table is being edited to have the program act accordingly. I have tried a few things, but none of the solutions are practical, and are too slow. Does anyone know of a good way to go about this? Any help is appreciated.
Asked
Active
Viewed 181 times
-1
-
1Show us some example code of what you've tried. – Ally Jul 26 '12 at 21:24
-
What you're looking for is AJAX. Probably the easiest way to make AJAX requests would be to use JQuery's Ajax function. If you're looking for something out-of-the-box, you probably should look a CMS solution rather than anything else. P.S. How to know which cell is being updated? Read about the "this" keyword in javascript or jquery. – Ozzy Jul 26 '12 at 21:26
2 Answers
0
I assume you are using input or textarea tags inside the table cells ? If so you can use the jquery library to bind a handler to the 'keyup' event generated, inside that handler you can query attributes of the element that raised the event. Use an algorithm to set unique ids or classes for row and column helps you to identify the position you are looking for. Then you can make an ajax request to the server holding the computed values.

arkascha
- 41,620
- 7
- 58
- 90
0
Seems that for many this is the answer:
$('td').click(function(){
var col = $(this).parent().children().index($(this));
var row = $(this).parent().parent().children().index($(this).parent());
alert('Row: ' + row + ', Column: ' + col);
});
as per here: Table row and column number in jQuery
-
So this would do the job in general, but I am using handsontable(http://warpech.github.com/jquery-handsontable/) which seems to be using a text area for the input, and adding the input to a table which is in the format of the spreadsheet. I wanted to know which column of the spreadsheet was being updated and thought that this would do the trick, but now that I try it it doesnt work. – user1410270 Aug 01 '12 at 21:47