Click here to Skip to main content
16,021,687 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
XML
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:-

C#
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]);
               });
              }
				   }
	      });
           });


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...
Posted
Updated 16-May-14 21:38pm
v5
Comments
[no name] 16-May-14 8:58am    
why are you not using jquery for sort table
p@y@l 17-May-14 0:03am    
I have tried some but dint get the correct code.I have tried using the sort query and sorted but I find it difficult to display the values sorted on the same table.
[no name] 17-May-14 0:51am    
jquery looks like that but not...
p@y@l 17-May-14 0:56am    
sorry ,I dint get you..
[no name] 17-May-14 1:26am    
you can do in jquery also

1 solution

See this article for sort order to html table
http://tablesorter.com/docs/[^]
 
Share this answer
 
Comments
p@y@l 17-May-14 7:41am    
oh..k..i will try that..thanks :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900