Copy code code as follows:
<div ID = "html"> </div>
<script>
var listinfos = new array ();
listinfos [0] = new array ();
listinfos [0] [0] = {'name': 'Recommended page 1', 'daycount': 666, 'avgtime': 29872, 'errcount': 180663, 'errorraate': '2873%', 'daysystemErrorRerrorRerrorRerrorRerror Count ': 0.
listinfos [0] [1] = {'name': 'Recommended page 2', 'daycount': 593896, 'avgtime': 24946, 'errcount': 222, 'errorraate': '2%', 'DaySystemErrorCou nt ': 0.
listinfos [0] [2] = {'name': 'Recommended page 3', 'daycount': 956, 'avgtime': 27957, 'errcount': 111, 'errorraate': '10%', 'daysystemSemerCount' Besides 0.
listinfos [1] = new array ();
listinfos [1] [0] = {'name': 'Recommended page 4', 'daycount': 666, 'avgtime': 116, 'errcount': 180663, 'errorraate': '2873%', 'daysystemErrorCou nt ': 0.
listinfos [1] [1] = {'name': 'Recommended page 5', 'daycount': 11, 'avgtime': 222, 'errcount': 222, 'errorRate': '2%', 'daysystemErrorCount': 0.
listInfos [1] [2] = {'name': 'Recommended page 6', 'daycount': 956, 'avgtime': 956, 'errcount': 111, 'errorRate': '10%', 'daysystemErrorCount': 0.
Function datedesc (ListInfos, Field) {{
for (var I = 0; I <chistinfos.length; i ++) {
for (var j = i+1; j <listinfos.length; j ++) {
if (iSComMapercent (ListInfos [i] [field]) <IsCommapercent (listinfos [J] [Field])) {) {
var arrayTemp = New Array ();
arrayTemp = listinfos [i];
listinfos [i] = listinfos [j];
listinfos [j] = arrayTemp;
}
}
}
Return listinfos;
}
Function dataASC (ListInfos, Field) {
for (var I = 0; I <chistinfos.length; i ++) {
for (var j = i+1; j <listinfos.length; j ++) {
if (iSComMapercent (listinfos [i] [field])> IsCommapercent (listinfos [j] [field])) {) {
var arrayTemp = New Array ();
arrayTemp = listinfos [i];
listinfos [i] = listinfos [j];
listinfos [j] = arrayTemp;
}
}
}
Return listinfos;
}
Function isCommapercent (Value) {
var valueFloat;
value = value.tolocalestring ();
valueFloat = (Value.indexof (',')> 0)? Value.split (','). Join (''): value;
ValueFloat = (ValueFloat.indexof ('%')> 0)? PARSEFLOAT (valueFloat.Substr (0, valueFloat.indexof ('%')): PARSEFLOAT (ValueFloat);
Return valueFloat;
}
Function Sortoperation (Sortinfos, Field, SORT) {{
var listinfos = new array ();
if (sort == 'desc') {{
for (var I = 0; I <sortinfos.length; i ++) {
listInfos [i] = DateDesc (sortinfos [i], field);
}
} else if (sort == 'asc') {
for (var I = 0; I <sortinfos.length; i ++) {
listInfos [i] = dataASC (sortinfos [i], field);
}
} Else {
alert ('operation error ...');
Return false;
}
var tablestrist = '';
for (var I = 0; I <chistinfos.length; i ++) {
var tablestr = '<h1> program </h1>';
tablestr+= '<table cellspacing = "0" cellpadding = "0"> <tbody> <ter>';
Tablestr += '<TD> program name </td> <TD> Visits of the day (times) </td> <TD> average response time (US) </td> <TD> Error number (times) </td > ';
tablestr += '<TD> error rate (%) </td> <TD> System error (times) </td> <td> System error rate (%) </td> </tr>';
for (var j = 0; j <listinfos [i] .Length; j ++) {
tablestr += '<ter>';
tablestr+= '<td> <a href = "Detail.php? Type = ProgramS & Pid = 1">'+listinfos [i] [j] ['name']+'</a> </td>';
tablestr+= '<td>'+listinfos [i] [j] ['daycount']+'</td>';
tablestr+= '<td>'+listinfos [i] [j] ['avgtime']+'</td>';
tablestr+= '<td>'+listinfos [i] [j] ['errcount']+'</td>';
tablestr+= '<td>'+listinfos [i] [j] ['errorraate']+'</td>';
tablestr+= '<td>'+listinfos [i] [j] ['daysystemerRerCount']+'</td>';
tablestr+= '<td>'+listinfos [i] [j] ['daysystemerRRRATE']+'</td>';
tablestr += '</tr>';
}
tablestr += '</tbody> </table>';
tablestrist += Tablestr
}
document.GetelementByid ("html"). Innerhtml = tablestrist;
}
sortoperation (listinfos, 'daycount', 'asc')
</script>