"dmsc17454_2" <dm*********@blueyonder.co.uk> skrev i meddelandet
news:Qm*******************@news-text.cableinet.net...
Ok, slight help need with editing this "sorttable.js" file. I have no
experience with Javascript
// Work out a type for the column
if (table.rows.length <= 1) return;
var itm = ts_getInnerText(table.rows[1].cells[column]);
sortfn = ts_sort_caseinsensitive;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^\d\d[\/-]\d\d[\/-]\d\d$/)) sortfn = ts_sort_date;
if (itm.match(/^[£$]/)) sortfn = ts_sort_currency;
if (itm.match(/^[\d\.]+$/)) sortfn = ts_sort_numeric;
SORT_COLUMN_INDEX = column;
var firstRow = new Array();
var newRows = new Array();
for (i=0;i<table.rows[0].length;i++) { firstRow[i] = table.rows[0][i]; }
for (j=1;j<table.rows.length;j++) { newRows[j-1] = table.rows[j]; }
Basically, I want my dates to display like "12th May 2004" instead of
"12/5/2004", I think the code above is to do with this.
No, as the comment indicates, it uses regular expressions to guess what kind
of data the table contains based on how the content is formatted, then
assigns an appropriate sorting function (date, currency or numeric).
You might want to look up the javascript Date object. Probably you have to
parse the table cell content yourself and use it to initialize a Date with.
The Date can then be converted to text with various formatting options.
Joakim Braun