javascript sort column by textbox value

L

Liming

Hi all,

I'm try to use this javascript for sorting columns

http://www.kryogenix.org/code/browser/sorttable/

and the problem is, one of the columns I have is a textbox and when
sort on that column, I need to extract the values of the textbox and
sort. I think i can deal with the sorting once i get the value, but how
do I get the value of a textbox in a column?

This is the source file
http://www.kryogenix.org/code/browser/sorttable/sorttable.js


I've narrowed it down to these two method

function ts_getInnerText(el) {
if (typeof el == "string") return el;
if (typeof el == "undefined") { return el };
if (el.innerText) return el.innerText; //Not needed but it is faster
var str = "";

var cs = el.childNodes;
var l = cs.length;
for (var i = 0; i < l; i++) {
switch (cs.nodeType) {
case 1: //ELEMENT_NODE
str += ts_getInnerText(cs);
break;
case 3: //TEXT_NODE
str += cs.nodeValue;
break;
}
}
return str;
}
function ts_resortTable(lnk) {
.....
var itm = ts_getInnerText(table.rows[1].cells[column]);
....
}

but this is gettign the "text content" of the column, when encounters
input box, obvioulsy, I need to futher parse the tag. I'm a bit lost, I
know I have to add a nodeType or something inside of ts_getInnerText,
can anybody point me to the right direction? Thanks
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top