im trying to get the user to enter information into a textbox and then after clicking submit button the page has a table containing with that information in the rows.
so for example the table has the heading Artist, Songs, Year made, Gene
and the user has to enter data for each feild inside a text box and it store it in here.
this is what i have so far


<H2>JavaScript Sort Table</H2>

    function sortTable(col, myTable){
var cell = col + myTable.cols;
var totalRows = myTable.rows.length;
var tSort = 0;
var columns = new Array();
var index = new Array();
var indexArray = new Array();
var array = new Array();
var newRow;
var newCell;
var i,j,k;
for (i=1; i < myTable.rows.length; i++) {
columns[i - 1] = myTable.cells(cell).innerText;
cell = cell + myTable.cols;
for (i=0; i < columns.length; i++){
array[i] = columns[i];
for (i=0; i < columns.length; i++){
indexArray[i] = (i+1);
for(j=0; j < array.length; j++){ 
if (columns[i] == array[j]){ 
for (k=0; k<i; k++){
if ( index[k] == (j+1) ){
tSort = 1;
if (tSort == 0){
index[i] = (j+1);
tSort = 0;
for (i=0; i<index.length; i++) {
newRow = myTable.insertRow();
for (k=0; k<myTable.cols; k++) {
newCell = newRow.insertCell();
newCell.innerHTML = myTable.rows(index[i]).cells(k).innerHTML;
for (i=1; i<totalRows; i++){
myTable.moveRow((myTable.rows.length -1),1);
for (i=1; i<totalRows; i++){


<TABLE WIDTH="55%" BORDER="1" name="table" id="table" cols="4">
<TR><TD><A href="javascript:sortTable(0, table);"><FONT color="red"><B>Artist</FONT></B></A></TD>
<TD><A href="javascript:sortTable(1, table);"><FONT color="red"><B>Songs</FONT></B></A></TD>
<TD><A href="javascript:sortTable(2, table);"><FONT color="red"><B>Year</FONT></B></A></TD>
<TD><A href="javascript:sortTable(3, table);"><FONT color="red"><B>Gene</FONT></B></A>
<TR><TD>Jlo</TD><TD>what goes around</TD><TD>2000</TD><TD>hip hop</TD></TR>
<TR><TD>50 cent</TD><TD>stright to the bank</TD><TD>2003</TD><TD>rap</TD></TR>
<TR><TD>Katy perry</TD><TD>i kissed a girl</TD><TD>2010</TD><TD>pop</TD></TR>
<TR><TD>jay-Z</TD><TD>99 problems</TD><TD>1999</TD><TD>Rap</TD></TR>

Recommended Answers

All 2 Replies

So, the code you provided thus far shows a table and a "header" type row that executes a function that is to supposed to sort the column.

Can you elaborate more on what you are trying to do with regard to the text box and the submit button? They werent included in this code. Are you trying to pass data between pages, same page, etc.?

where is the code for submiting data can you post that code also

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.