Changing <div> content not working.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chris1606
    New Member
    • Oct 2006
    • 3

    Changing <div> content not working.

    I have an image gallery that pops up an enlarged version of a picture when someone clicks on it. That bit works, but it should also load the picture's caption into the floating layer. Instead the caption remains unchanged and gives an "object doesn't support this property or method" dialog.

    The code is as follows:

    Code:
    <script>
      function goBig(objNo, caption)
      {
      document.getElementById('floatdiv').style.visibility = 'visible';
      document.getElementById('floatimg').src = document.getElementById('i'+objNo).src;
      document.getElementById('dd1').style.visibility = 'hidden';
      document.getElementByID('floatTxt').innerHTML = caption;
      }
    </script>
    Code:
    <a href="#" onClick="goBig('2','This is the caption');">
    <img src="image.jpg" height="100" width="150" border="0" id="i2" />
    </a>
    Code:
    <div id="floatdiv" [style code/closing javascript removed to keep things short]><img id="floatimg" src="blank.gif" style="width: 800px">
    <br />
    <div id="floatTxt">.</div>
    Click on the image to close.</div>
    Thanks in advance.
  • Thevercad
    New Member
    • Oct 2006
    • 26

    #2
    hi,

    can you try the following code?

    Code:
    document.getElementByID('floatTxt').innerText = caption;
    I think, this might work.

    Comment

    • chris1606
      New Member
      • Oct 2006
      • 3

      #3
      Just tried that, it didn't work at first, but then I spotted the capital "D" in getElementById in my original code. :p.

      All working now, cheers for the help.

      Comment

      • Thevercad
        New Member
        • Oct 2006
        • 26

        #4
        Sorry about that mistake. I'm glad its working now. :-)

        Comment

        Working...