954,595 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

does <img tag has disable property

hi all,

i am using an image as a button. so i want to disable it on some actions.

so i used
document.getElementById("imagName").disabled = true;

but it seems that this property is not working for

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

disabled only works on form elements.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

but this image also in the form..

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

But it is not a form element. A form element is something like and .

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

but
http://www.java2s.com/Code/JavaScriptReference/Javascript-Properties/disabledisappliedto.htm

in the above page it is mentioned that dasabled property can be applied for

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

It might be in the specs as being allowed but obviously browsers don't support it.

stymiee
He's No Good To Me Dead
Moderator
3,360 posts since May 2006
Reputation Points: 161
Solved Threads: 38
 

If you use:

<input type="image" src="[href to image]"/>

You should be able to disable it. That's a valid input type; it should be supported widely.

Alterantively; try:

<button><img src="[href to image]"/></button>


You might have to restyle the button to stop it being drawn as an actual button... but the button will have a disabled property; and disabling the button will stop the image being clicked/prevent the button from being functional.

See: http://www.w3.org/TR/html4/interact/forms.html#h-17.4

MattEvans
Veteran Poster
Moderator
1,386 posts since Jul 2006
Reputation Points: 522
Solved Threads: 64
 

[href to image]

this is the way i am useing the image as a button.
is this possible to disable.....?

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

i believe you can. add id property and then try and disable. Pls get back to me. that is [href to image][href to image] this is the way i am useing the image as a button. is this possible to disable.....?

jamello
Posting Whiz in Training
219 posts since Oct 2006
Reputation Points: 215
Solved Threads: 6
 

ya. i have already used the id property to access it, but still it is not working. i am using the Mozilla browser. so the way to access the image is as follow.

document.getElementById("add").disabled = true;

rpjanaka
Junior Poster in Training
69 posts since Sep 2006
Reputation Points: 10
Solved Threads: 0
 

This might be a mozilla stuff. I have used it this way and it works. Did you try what MattEvans suggested?
ya. i have already used the id property to access it, but still it is not working. i am using the Mozilla browser. so the way to access the image is as follow.

document.getElementById("add").disabled = true;

jamello
Posting Whiz in Training
219 posts since Oct 2006
Reputation Points: 215
Solved Threads: 6
 

Dude, you have the answer above already...the onClick parameter is ALWAYS going to run when clicked... this is NOT form input.... The input tag with type="image" is the CORRECT way to use an image as a button... if you don't do it correctly even when people tell you, then there is little we can do...

Now to do it your way, don't use disable, but hide the button all togther then it isn't being enabled... if they can't see it they can't click it, so your onClick won't be an issue...

OK, but I highly recomend using the proper method of input tag with type="image" parameter set.

rgtaylor
Junior Poster in Training
88 posts since Mar 2007
Reputation Points: 10
Solved Threads: 2
 

[href to image]

this is the way i am useing the image as a button. is this possible to disable.....?

I don't think disabled works on an as you have it. Why not just use javascript to check if you've disabled an image?

eg:

[HTML]onclick="if(!this.disabled)sendAdd();"[/HTML]

digital-ether
Nearly a Posting Virtuoso
Moderator
1,293 posts since Sep 2005
Reputation Points: 461
Solved Threads: 101
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You