Input Type Image and disabled

P

petermonsson

Hi all,

Does IE support disabled for the Image type in inputs? This small
example doesn't seem to work when the type is Image, but perfectly fine
when the type is submit.

Best Regards

<html>
<head>
<title>Lala</title>
</head>
<body>
<script>
<!--
function disable()
{
var button = document.getElementById("submit");
button.disabled = true;
button.style.color = "red";
return false;
}
-->
</script>
<form action="world.html" onsubmit="return disable()">
<input type="image" id="submit" src="Hello" Value="submit
"Alt="Submit">
</form>
</body>
</html>
 
B

Bart Van der Donck

Does IE support disabled for the Image type in inputs? This small
example doesn't seem to work when the type is Image, but perfectly fine
when the type is submit.
[snip code]

It appears to work (WinXP IE 6.0.29), but the disable-command is not
directly "visible" for the user. The image is just displayed whether
it's enabled or not. It should work for all INPUT-elements (at least in
HTML4.0+) regardless of the TYPE-argument:

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

If you would decide to use the code, maybe you could swap your image to
another one that is more in "disabled-style" when the element is
actually disabled.

Hope this helps,
 
P

petermonsson

Bart said:
It appears to work (WinXP IE 6.0.29), but the disable-command is not
directly "visible" for the user.

You're right. It actually works, although it doesn't seem so for the
user. if I put in this conditional

....
if(button.disabled == true)
alert("Error");
button.disabled = true;
....

then the alert box never displays. But then there is one thing that
puzzles me: When I use this snippet in an other system I still recieve
double form submissions when testing...
 
B

Bart Van der Donck

You're right. It actually works, although it doesn't seem so for the
user. if I put in this conditional

if(button.disabled == true)
alert("Error");
button.disabled = true;

then the alert box never displays.

That obviously depends on where you put it in your code. It should work
if you put it just before:

button.style.color = "red";

Your 'disable()'-function can be executed only once anyhow - after it's
done, the submit element is left disabled, so you can't execute the
'disable()'-function again.
But then there is one thing that
puzzles me: When I use this snippet in an other system I still recieve
double form submissions when testing...

Well, your code actually prevents form submissions.
You might invoke a processing script twice if you doubleclick on a
submit element. The rule is "one click = one submit".
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top