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
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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.