I want to click on a table header and do some processing to update the table. i have a function mySort which is called when you click on a table header. It sets some fields on the page and calls a second function which does the xmlHttp.open and the xmlHttp.onreadystatechange calles. everything works fine the first time I click on a header. The fields are updated, the table is updated, there are no error messages in the Firefox error console or the Firebug window. However If I click on a header a second time I get an error message that mySort is not a function.
I have tried everything I can think of to fix this problem. I even went back to an old copy and reapplied all of the changes one by one until it stopped working to make sure that is where the problem was. I have also tried returning the onclick property from the PHP script.
In the PHP script I look up the new information for the table and rerturn the formatted table minus the tables tags. I then add the Table tags and the header line in the Javascript. everything works fine and keeps working it I take out the onclick property.
Below is the Javascript I am having problems with. I have examined the HTML before and after running the mySort function and I can find no differences.
Expand|Select|Wrap|Line Numbers
- myTable = '<table border=1><tr><th>Sel</th>';
- myTable = myTable + '<th\ onClick=\"mySort(\'pri\', 1 );\">pri</th>';
- myTable = myTable + '<th>Date</th><th>Rqstr</th><th>Status</th><th>Desc</th></tr>';
- myTable = myTable + statusRSP;
- myTable = myTable + '</table>';
- document.getElementById("Layer2").innerHTML = myTable;
Thanks for any suggestions. If there is a better way to return the table from the PHP script please let me know.