Problem with getElementsById(ImgName).

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jags
    New Member
    • Mar 2009
    • 3

    Problem with getElementsById(ImgName).

    Hi All

    I could not display my image through this getElementsById (ImgName).Pleas e let me what is wrong with this piece of code .I have stored all my images in the Doclib of sharepoint site.The last line of the code is throwing error also do let me know in case if we have any other alternate solutions to display my image.

    Thanks
    Jag



    Code:
    <span class="srch-Icon"> 
    <img alt="n1" id="{concat('IMG_',$id)}"  src="http://a2ms04866:3000/Pdfimage/_t/pdf%5Ficon%5Fsmall_gif.jpg" onmouseover ="javascript:cool1('{concat('IMG_',$id)}','{title}')"/>
    
    <script language="javascript">
    
    function cool()
    {
    alert("hii");
    }
    
    function cool1(ImgName, Title)
    {
    alert(ImgName);
    alert(Title);
    var i=Title.indexOf(".");
    var xcv=Title.substring(0,i);
    var imagepath='http://a2ms04866:3000/Pdfimage/'+xcv+'.jpg';
    alert(imagepath);
    document.getElementsById(ImgName).src=imagepath;
    //alert(imagepath);
    }
    
    </script>
    Last edited by Dormilich; Mar 19 '09, 12:07 PM. Reason: added [code] tags
  • acoder
    Recognized Expert MVP
    • Nov 2006
    • 16032

    #2
    The problem is that document.getEle mentsById() doesn't exist. It's document.getEle mentById() (without the 's'):
    Code:
    document.getElementById(ImgName).src=imagepath;

    Comment

    • jags
      New Member
      • Mar 2009
      • 3

      #3
      thanks a lot and it worked for me !!

      Regards
      Jag

      Comment

      • acoder
        Recognized Expert MVP
        • Nov 2006
        • 16032

        #4
        No problem :) and welcome to Bytes! If you're new to JavaScript, you may want to check out the sticky at the top for useful links.

        Comment

        Working...