sortering af cookie elementer
Jeg har flg funktion som skriver bestillinger i en tabel.Hver linie starter med en dato i formatet 03-maj-00
Jeg ville gerne have sorteret tabellen så den er ordnet efter dato. ???
function showItems() {
index = document.cookie.indexOf(\"TheBasket\");
countbegin = (document.cookie.indexOf(\"=\", index) + 1);
countend = document.cookie.indexOf(\";\", index);
if (countend == -1) {
countend = document.cookie.length;
}
fulllist = document.cookie.substring(countbegin, countend);
totprice = 0;
document.writeln(\'<TABLE BORDER cellpadding=\"2\" align=center>\');
document.writeln(\'<TR><TD><b><font face=\"Arial\" size = \"2\">Dato Art</font></b></TD><TD><b><font face=\"Arial\" size = \"2\">Antal</font></b></TD><TD><b><font face=\"Arial\" size = \"2\">Pris pr. stk.</b></TD><td><b><font face=\"Arial\" size = \"2\">Total</font></b><TD align=center><b><font face=\"Arial\" size = \"2\">Fortryd</b></TD></TR>\');
itemlist = 0;
for (var i = 0; i <= fulllist.length; i++) {
if (fulllist.substring(i,i+1) == \'[\') {
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == \']\') {
itemend = i;
thequantity = fulllist.substring(itemstart, itemend);
itemtotal = 0;
itemtotal = (eval(theprice*thequantity));
temptotal = itemtotal * 100;
totprice = totprice + itemtotal;
itemlist=itemlist+1;
document.writeln(\'<tr><td><font face=\"Arial\" size = \"2\">\'+theitem+\'</font></td><td align=center><font face=\"Arial\" size = \"2\">\'+thequantity+\'</font></td><td align=right><font face=\"Arial\" size = \"2\">\'+theprice+\'</font></td><td align=right><font face=\"Arial\" size = \"2\">\'+top.shop.alterError(itemtotal)+\'</font></td><td><font size = \"1\" face=\"Arial\"><a href=\"java script:removeItem(\'+itemlist+\')\">Fjern denne linie</a></font></td></tr>\');
} else if (fulllist.substring(i,i+1) == \',\') {
theitem = fulllist.substring(itemstart, i);
itemstart = i+1;
} else if (fulllist.substring(i,i+1) == \'#\') {
theprice = fulllist.substring(itemstart, i);
itemstart = i+1;
}
}
document.writeln(\'<tr><td colspan=3><b><font face=\"Arial\" size = \"2\">I alt DKK</font></b></td><td align=right><font face=\"Arial\" size = \"2\">\'+top.shop.alterError(totprice)+\'</font></td> <td><font face=\"Arial\" size = \"2\"> DKK</font> </td> </tr>\');
document.writeln(\'</TABLE>\');
}
