AJAX Javascript Variable Help!

Here is my predicament. I am working on an AJAX grid. Basically AJAX to load a database table and when wanted click the row to edit, and text fields pop up in place of text, make your changes and you’re done. Anyway, everything works great! My problem lies with the format of the grid. It becomes quite large and overruns the browser window. What I tried to do was trim the entries to only show say 10 characters so instead of seeing ‘Chace Louis Prochazka’ in the field you would see ‘Chace Loui…’ allowing for a better looking table. The only problem is that when converting the text into a text field using the DOM object it input’s the shortened ‘Chace Loui…’ instead of what is really there, the full name.

Anyhow I created some new functions that will use the row ID to pull all the columns for that ID and return them by the column name, and this is where it gets nasty. I call a javascript function that replaces each cells text with a text field and puts the text in the text field. Now I have another Javascript function that uses a couple PHP functions to pull the info for that row to put it in the text field. I can use an alert() in the javascript function and it gives me the correct data. If I try to set a Javascript variable and then set the text field to that variable it is always one request behind, in that on the first click I get ‘undefined’ but on the second click I get the info I wanted from the original click.

I think it has to do with how variables are processed in Javascript and possibly the fact that the Javascript file is used for the initial function, then uses two other functions in the same file from within the same file. Is there a way to make sure my variables are ‘up-to-date’ or refresh the javascript file so that my variables can be set within the file rather than re-loading the file?

I know this might not make any sense at all but I hope someone feels my pain!