• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

how to take values into java script array which are displayed in html table.

 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,
i've one doubt that how to assign values into javascript array which are displayed in html table. Even this table is created using javascript.Here is the code follows:

function AddTime()
{
var rowinx = document.getElementById("tab").rows.length;
if(rowinx > 6 )
{
alert("Only Limited Time Schedules are allowed");
}
else
{
var rr = document.getElementById("tab").insertRow();
var cc1 = rr.insertCell();
cc1.innerHTML="<font face='verdana' size='1'>"+ document.createreport.hour.value +"</font><input type='hidden' name='hr' value="+document.createreport.hour.value+"><input type='hidden' name='mins' value="+document.createreport.min.value+">";
...............
}
}


<table id='tab' border='1' align='left'>
<tr>
<td><font size='1' face='verdana'><b>Hrs</b></font></td>
<td><font size='1' face='verdana'><b>Mins</b></font></td>
<td>  </td>
</tr>
<% // ***this method displays earlier selected Scheduling
Timings in a table***
out.println(psr.getSchedules(siteid));
%>
</table>

now i want to sort the given values. how can i do this . please help me.
 
Ranch Hand
Posts: 64
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Setting the innerHTML property is a bit too basic for this purpose. You'll have to use the HTML DOM. There's a tutorial on w3schools:
http://www.w3schools.com/dom/default.asp

You can write a simple bubble-sort algorithm that manipulates the DOM tree directly, so that you don't even have to load the values into an array first. It's not beginner stuff, but I wouldn't exactly call it advanced material either. Shouldn't take you more than a day.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic