[Javascript] innerHTML misplacing text

lists at jdpill.com lists at jdpill.com
Mon Aug 27 16:17:23 CDT 2007


I have an oddity (possibly due to my lack of familiarity with javascript)...

I'm trying to drop some html into a DIV, and while the text *is* being
placed in the html file, it is being put in the wrong place.  In the code
below, rather than putting it in the specified element, it is putting the
text just after the button.  Any ideas why?

the bare-bones function:

function OnExistingSiteSwap(){
    document.getElementById("existingSiteOption").innerHTML = "<td>Hello
World!</td>";
}

and the HTML:

<body onload="javascript:OnExistingSiteSwap()">

<form name = "tedcform" action="/tedc/php/dbpost.php" method="post">
  <input name="Submit" type="submit" value="Submit" />

  <input name="formID" type="hidden" value="<? echo md5($loadTime) ?>" />
  <input name="formmode" type="hidden" value="<? echo $mode ?>" />
  <input name="<? echo md5($loadTime) ?>_bldSiteID" type="hidden" value="" />
  <input name="<? echo md5($loadTime) ?>_bldBuildingID" type="hidden"
value="" />

  <table>
    ...
    <tr>
      <div id="existingSiteOption"></div>
    </tr>
    ...
  </table>
   ...
</form>


thanks,

John





More information about the Javascript mailing list