Web Analytics Made Easy -
StatCounter setting innerHTML has no effect - CodingForum

Announcement

Collapse
No announcement yet.

setting innerHTML has no effect

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • setting innerHTML has no effect

    why does "b" doesn't change to "dddddddddd". here is the link to below code-->

    http://86.61.66.17:8084/AgroZoo/testHTML/testHTML.html

    click on fffff

    thanks for help.

    Code:
      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"  "http://www.w3.org/TR/html4/loose.dtd">
    <html>
      <head>
        <title>Untitled Document</title>
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
        <meta http-equiv="Content-Style-Type" content="text/css">
        <meta http-equiv="Content-Script-Type" content="text/javascript">
      <script type="text/javascript">
      function setTargetChildInnerHTML(parentNodeObj,subElementCount)
      {
        var groupArray = parentNodeObj.getElementsByTagName("DIV");
        //alert(parentNodeObj.getElementsByTagName("DIV")); 
        var TDnodeObj = groupArray[subElementCount];
        alert(groupArray[1].id);
        groupArray[1].innerHtml ="dddddddddd";
      }
      </script>
      </head>
      <body id = 'BODYID' onLoad = 'myFunc()'>
    
        <div onClick = 'setTargetChildInnerHTML(this,1)'>
          ffffff
          <div id = 'child0'>
            a 
          </div> 
          <div id = 'child1'>
            b 
          </div>
          <div id = 'child2'>
            c
          </div>
        </div>
      </body>
    </html>
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #2
    solved:

    -->

    http://86.61.66.17:8084/AgroZoo/testHTML/testHTML.html

    Code:
    while(groupArray[1].firstChild) groupArray[1].removeChild(groupArray[1].firstChild);
    
        groupArray[1].appendChild(document.createTextNode("dddddddddd"));

    but this look messy, is there any cleaner solution ?
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

    Comment


    • #3
      hrm...seems to me using something like

      groupArray[1].firstChild.innerHTML = 'dddddd'; would be logical, but i havent bothered w/ the code, so could be completely wrong. Dom is tricky.
      Active PHP/MySQL application developer available for immediate work.
      syosoft.com mavieo.com - Remote Web Site Administration Suite - Reseller Ready

      Comment


      • #4
        Yes, you have to write innerHTML, notice the upper case HTML.
        I had the same problem and tried days to find it, especially as no debugger saw this as a problem.

        Comment


        • #5
          the problem in your first code is that you have used lowercase innerHtml instead of the correct innerHTML

          On the other hand innerHTML is not a standard DOM method. DOM is

          element.firstChild.data
          or
          element.firstChild.nodeValue
          KOR
          Offshore programming
          -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

          Comment

          Working...
          X