Flash Games

 FAQ   Search   Members   Groups   Register  User Control Panel      Login 

Your time now:
Mon Nov 23, 2009 12:06 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 8 posts ]  Bookmark and Share
Author Message
 Post subject: How to put .gif image using java script
PostPosted: Mon Nov 17, 2008 3:44 pm 
Offline

Joined: Tue Nov 04, 2008 1:08 pm
Posts: 21
Hi :D
If i click on upload button i must get an .gif image , is it possible , in the code below
Code:
<INPUT type="button" name="btnUpload" id="btnUpload" value="Upload" onclick="validateField()" />


and this is my
source
Code:
<img src="images/action/animation/UploadStatus.gif"/>


How to put it in above code

My requirement is when the user click on upload button , he must see the UploadStatus.gif image .
please help

Regards


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 17, 2008 10:56 pm 
Offline

Joined: Mon Nov 17, 2008 6:50 am
Posts: 7
You *may* be able to try something like

Code:
function validateField() {

   var docs = document.getElementById("img");
   docs.setAttribute("src", "gif_path");

    ... // other code
}


Code:
<body>
...
<img id="img" src='#'>
...
</body>


Top
 Profile  
 
 Post subject: How to put .gif image using java script
PostPosted: Tue Nov 18, 2008 4:04 am 
Offline

Joined: Tue Nov 04, 2008 1:08 pm
Posts: 21
panzer wrote:
You *may* be able to try something like

Code:
function validateField() {

   var docs = document.getElementById("img");
   docs.setAttribute("src", "gif_path");

    ... // other code
}


Code:
<body>
...
<img id="img" src='#'>
...
</body>



Thanks a lot panzer , It worked , successfully , Thanks a lot for ur help

but it is showing a square box by default and when the upload button is clicked the .gif image is displayed , I dont need that square box .
i got the solution , but is there any way to remove the square box . Thanks
[/img]


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 11:35 am 
Offline
500+ Club
User avatar

Joined: Thu Jan 25, 2007 2:10 pm
Posts: 691
Location: Midlands, England
You could try something like:
Code:
<img id="img" src='#' style="display:none">
and
Code:
function validateField() {

   var docs = document.getElementById("img");
   docs.setAttribute("src", "gif_path");
   docs.style.display = 'block';

    ... // other code
}


Hope that helps,
Flabby Rabbit

_________________
http://www.hackthis.co.uk


Last edited by flabbyrabbit on Tue Nov 18, 2008 5:21 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 2:57 pm 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
Flabby, there's no solid value on CSS' display property.

This part is erroneous:
Code:
docs.style.display = 'solid';


For further reading:
http://www.w3schools.com/css/pr_class_display.asp

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
 Post subject:
PostPosted: Tue Nov 18, 2008 5:21 pm 
Offline
500+ Club
User avatar

Joined: Thu Jan 25, 2007 2:10 pm
Posts: 691
Location: Midlands, England
I meant "block", sorry.

Edited post.

Flabby Rabbit

_________________
http://www.hackthis.co.uk


Top
 Profile  
 
 Post subject: Re: How to put .gif image using java script
PostPosted: Wed Nov 19, 2008 12:33 am 
Offline

Joined: Mon Nov 17, 2008 6:50 am
Posts: 7
neha_kulkarni777 wrote:
but it is showing a square box by default and when the upload button is clicked the .gif image is displayed , I dont need that square box .
i got the solution , but is there any way to remove the square box . Thanks

You can try adding border="0" to the img tag.
Code:
<img id="img" src="" border="0">

You can also try a masked image instead of using src="". Another option *may* be to use the div tag and innerHTML, but I don't know how how well it's supported by different browsers.
Code:

function validateField() {

   var docs = document.getElementById("container");
   docs.innerHTML = "<img src="gif_path">;

    ...  // other code
}
...
<body>
<div id="container"></div>
...


Hope that helps.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 19, 2008 1:29 am 
Offline
500+ Club
User avatar

Joined: Wed Feb 27, 2008 6:14 am
Posts: 929
Location: Cebu City Philippines
flabbyrabbit wrote:
I meant "block", sorry.

Edited post.

Flabby Rabbit


That would work well, but image is (by default) an inline-element.

Changing it to block-level element (as by changing it's display property to block) isn't a desired effect.

We only want to toggle the image's display.

You can leave the value an empty space:
Code:
docs.style.display=''

...this also means a positive display.

Hope that makes sense ;)

@panzer,

Don't use the border attribute - it's deprecated:
http://www.w3.org/TR/REC-html40/index/attributes.html
http://www.codehelp.co.uk/html/deprecated.html

_________________
~ Get me some work, I do freelancing ~


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 8 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group - Flash Games - TNX Invitation Code - TNX Review


Webmaster - Excruciating - Johnathan - Kotik - Ash - Tomi - rangana - Phate - dflynn - Medley