0

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

Edited by pritaeas: Being resurrected

6
Contributors
12
Replies
16
Views
10 Years
Discussion Span
Last Post by digital-ether
0

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

0

<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.....?

0

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>

<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.....?

0

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;

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;

0

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.

0

<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.....?

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

eg:

onclick="if(!this.disabled)sendAdd();"