本文介绍了Javascript - 如何排序表?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
myTable= "<table id='name' bgcolor='#00cafe' border=1 >";
myTable+="<tr><td id='r'></td><td id='r1'></td></tr>";
//myTable.fontcolor('#00cafe;');
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
var name= row.Cust_name;
var userid=row.UserId;
var myArray = new Array();
myArray[i]=name;
myTable+="<tr><td id='r' style='width: 600px; padding: 0.5em 0 0.1em 0; text-align: left;'>" + myArray[i] + "</td><td id='r1'><div class='progress'><div class='progress-bar' style='width:0%'></td></tr>";
// td.innerHTML= '<div class="progress"><div class="progress-bar" style="width:14%">';
}
myTable += "</table>";
document.getElementById('myDynamicTable').innerHTML=myTable;
额外代码: -
extra code:-
db1=openDatabase(id, version, displayName,maxSize);
db1.transaction(function(transaction)
{
var query='SELECT * FROM customer ORDER BY Cust_name';
transaction.executeSql(query , [], function(transaction, result)
{
le=result.rows.length;
if (le != 0)
{
for (var i = 0; i < result.rows.length; i++)
{
var row = result.rows.item(i);
var name= row.Cust_name;
var myArray = new Array();
myArray[i]=name;
jQuery('.sorting').each(function()
{
jQuery('.r').html(myArray[i]);
});
}
}
});
});
如何对此表进行排序?我在此表中包含某些值。当我单击时按钮排序,我需要这个表根据Cust_name字段排序。我怎么能这样做?
请帮助...
How to sort this table?I have this table with certain values in it.When I click the button to sort, I need this table to get sorted according to Cust_name field.How can I do this??
please help...
推荐答案
这篇关于Javascript - 如何排序表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!