I’m an experienced Ajax programmer using PHP but I’m having trouble understanding why this ajax code isn’t working. The thing that is different about this ajax code is that I am creating a table on a form that did not exist when the form was first loaded.
I have a php form. When I click on a link I want a table to be displayed with a width of 850, done using Ajax.
I can create the table fine using ajax but I can’t populate the table width attribute with my php variable holding the value of 850. The line snippet shown here creates the table ok:
[code=php]<TABLE ID=”table_width” border=0 width=”<?php echo $php_width?>”>
The JS code below would normally populate the table width with no problems:
[code=php]var table_width = ‘<?php echo $php_width?>’;
document.getElementById(‘table_width’).width = table_width;
HOWEVER, what I have determined is that since the table structure never existed before (when the form first loaded), the getElementById(‘table_width’).width statement doesn’t work.
If the table structure existed on the form when first loaded then of course it would work and set the table width.
So, this ajax problem is different from all of my other ajax coding because here I am trying to “ajax” a new table onto an existing form that was never there before AND then set its table width attribute. The table structure comes into the form fine but I can’t access it’s .width attribute using my php variables.
Does anyone know the fix for this?
Thanks…