JavaScript

Moderators: None (Apply to moderate this forum)
Number of threads: 2058
Number of posts: 5158

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Dyanamic load of images with in a single page Posted by malliksastry on 21 Apr 2004 at 9:21 PM
I want to write a program that dyanamically creates webpage taking an image and then add comment about the page
And finally I want all these to be added in a single webpage where in onclick of next and previous buttons the pages are to be displayed with in the same page

Please help me out in generating the code
Also I want the path to be taken as a relative path
Report
Re: Dyanamic load of images with in a single page Posted by zibadian on 21 Apr 2004 at 10:20 PM
: I want to write a program that dyanamically creates webpage taking an image and then add comment about the page
: And finally I want all these to be added in a single webpage where in onclick of next and previous buttons the pages are to be displayed with in the same page
:
: Please help me out in generating the code
: Also I want the path to be taken as a relative path
:
Here is a javascript function, which changes the image:
function changeImage(url)
{
  imgSpanID.innerHTML = '<img src="'+url+'">';
}

The HTML that goes along with it is this:
  <span id="imgSpanID"></span>

Place the HTML code anywhere where you want the image to be. You can modify the DHTML code the function creates as you wish. This can also be used to update the comment and to update the buttons.

A relative path is similar to a absolute path, but leaves certain parts out. So if you have your images located in a subfolder called "myimages" then you can call the function as follows:
  changeImage('myimages/someimage.jpg');

Report
Re: Dyanamic load of images with in a single page Posted by Weirdofreak on 22 Apr 2004 at 8:18 AM
I doubt that function'll work, AFAIK IDs aren't level two objects. There's also a more practical way - modify the image itself instead of the contents of its parent element:

:
: function changeImage(url)
: {
:   document.getElementById('pic').src = url;
: }
:
:   <img id="pic" src="temp.gif">
: 


If you don't want an image until the function is called, just use a 1x1 transparent gif.
Report
Re: Dyanamic load of images with in a single page Posted by zibadian on 22 Apr 2004 at 2:30 PM
: I doubt that function'll work, AFAIK IDs aren't level two objects. There's also a more practical way - modify the image itself instead of the contents of its parent element:
:
: :
: : function changeImage(url)
: : {
: :   document.getElementById('pic').src = url;
: : }
: :
: :   <img id="pic" src="temp.gif">
: : 

:
: If you don't want an image until the function is called, just use a 1x1 transparent gif.
:
I've used that same method to create several databases. It surely works under IE4+, Opera, and Netscape 4.5+.
Report
Re: Dyanamic load of images with in a single page Posted by Weirdofreak on 23 Apr 2004 at 7:34 AM
It doesn't work in Mozilla/Firefox.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.