943,964 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Feb 27th, 2007
0

does <img tag has disable property

Expand Post »
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 <img
because when i check it with text field by displying an alert

alert(document.getElementById("textField").disabled );

it will alert a boolean value. but when it checked with the image it will alert as "undefined"..

so i want to know that disable property is valid for <img

thanks..
janaka priyadarshana
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Feb 27th, 2007
0

Re: does <img tag has disable property

disabled only works on form elements.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Feb 28th, 2007
0

Re: does <img tag has disable property

but this image also in the form..
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Feb 28th, 2007
0

Re: does <img tag has disable property

But it is not a form element. A form element is something like <input> <select> and <textarea>.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Feb 28th, 2007
0

Re: does <img tag has disable property

but
http://www.java2s.com/Code/JavaScrip...sappliedto.htm

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

is that wrong...?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Mar 1st, 2007
0

Re: does <img tag has disable property

It might be in the specs as being allowed but obviously browsers don't support it.
Moderator
Reputation Points: 161
Solved Threads: 38
He's No Good To Me Dead
stymiee is offline Offline
1,422 posts
since May 2006
Mar 1st, 2007
0

Re: does <img tag has disable property

If you use:
HTML and CSS Syntax (Toggle Plain Text)
  1. <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:

HTML and CSS Syntax (Toggle Plain Text)
  1. <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
Moderator
Featured Poster
Reputation Points: 522
Solved Threads: 64
Veteran Poster
MattEvans is offline Offline
1,091 posts
since Jul 2006
Mar 14th, 2007
0

Re: does <img tag has disable property

<img src="[href to image]" name="add" onclick="sendAdd();">

this is the way i am useing the image as a button.
is this possible to disable.....?
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006
Mar 14th, 2007
0

Re: does <img tag has disable property

i believe you can. add id property and then try and disable. Pls get back to me.
that is

<img src="[href to image]" id="add" name="add" onclick="sendAdd();">

<script lang=javascript>
document.all.add.disabled = true;
</script>

Click to Expand / Collapse  Quote originally posted by rpjanaka ...
<img src="[href to image]" name="add" onclick="sendAdd();">

this is the way i am useing the image as a button.
is this possible to disable.....?
Reputation Points: 215
Solved Threads: 6
Posting Whiz in Training
jamello is offline Offline
219 posts
since Oct 2006
Mar 15th, 2007
0

Re: does <img tag has disable property

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;
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
rpjanaka is offline Offline
69 posts
since Sep 2006

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in HTML and CSS Forum Timeline: renegade footer...Help!!
Next Thread in HTML and CSS Forum Timeline: Why is this page center aligned?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC