Jump to content

Playing with innerHTML


ginerjm

Recommended Posts

The idea looks simple enough - so consequently I'm having a problem.

This is a bit of html I have in a table that I generate via PHP that I want to modify on-the-fly with JS:

echo "<tr class='pdata' id='row$i'><td>$k</td><td><input type='text' id='plyr$i' value='$v' size=3 maxlength=3 onchange='HandleSeedAssignment()'></td></tr>";

 

My JS function looks like this:

function ShowPlyrs()
{
     pobjs = document.getElementById('plyrtbl').getElementsByTagName("tr");
     nobjs = pobjs.length;
     alert("found "+nobjs+" tr elements");
     for (i=0;i<nobjs;i++)
     {
          pobj = pobjs[i];
          if (pobj['className'] =='pdata')
         {
                	document.getElementById(pobj.id).innerHTML = "<td>xyz</td><td>abc</td>";
         }
     }
     return;
}

It all works EXCEPT the last line that is supposed to re-write the <tr> element.  Running IE I'm getting "Unknown runtime error on line ###"  which is the line putting out the new innerHTML.

 

I've tried specifying my destination object a couple of ways.  Originally I tried

 

pobj.innerHTML  = "<td>xyz</td><td>abc</td>";

 

but that didn't work either.

 

Any ideas?  I'm sure it's simple.

Link to comment
https://forums.phpfreaks.com/topic/262094-playing-with-innerhtml/
Share on other sites

Ok - been doing some reading.  Some older posts found with G suggest that some elements are not re-writable with js.  Table is one of them.  So, if that is true, then I'll just have to alter my approach a bit.  Hope this helps the next person.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.