By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,370 Members | 1,590 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,370 IT Pros & Developers. It's quick & easy.

Problem with getElementsById(ImgName).

P: 3
Hi All

I could not display my image through this getElementsById(ImgName).Please 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



Expand|Select|Wrap|Line Numbers
  1. <span class="srch-Icon"> 
  2. <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}')"/>
  3.  
  4. <script language="javascript">
  5.  
  6. function cool()
  7. {
  8. alert("hii");
  9. }
  10.  
  11. function cool1(ImgName, Title)
  12. {
  13. alert(ImgName);
  14. alert(Title);
  15. var i=Title.indexOf(".");
  16. var xcv=Title.substring(0,i);
  17. var imagepath='http://a2ms04866:3000/Pdfimage/'+xcv+'.jpg';
  18. alert(imagepath);
  19. document.getElementsById(ImgName).src=imagepath;
  20. //alert(imagepath);
  21. }
  22.  
  23. </script>
Mar 19 '09 #1
Share this Question
Share on Google+
3 Replies


acoder
Expert Mod 15k+
P: 16,027
The problem is that document.getElementsById() doesn't exist. It's document.getElementById() (without the 's'):
Expand|Select|Wrap|Line Numbers
  1. document.getElementById(ImgName).src=imagepath;
Mar 19 '09 #2

P: 3
thanks a lot and it worked for me !!

Regards
Jag
Mar 19 '09 #3

acoder
Expert Mod 15k+
P: 16,027
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.
Mar 19 '09 #4

Post your reply

Sign in to post your reply or Sign up for a free account.