Problem Disabling Form Button
- From: "James" <jamesNO@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Mon, 17 Sep 2007 10:06:15 +0100
Hi,
I'm trying to use JavaScript to disable a form's submit button once it is
clicked once but I still want to submit the form after. I've written a
script which works in firefox, but for some reason, it does not work in IE7.
Here's what I have so far:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
window.onload = function() {
oneClick();
}
// Disable the curent button when clicked.
function oneClick() {
var buttons = document.getElementsByTagName("input");
for (var i=0; i < buttons.length; i++) {
if (buttons[i].getAttribute("type") == "button" ||
buttons[i].getAttribute("type") == "submit") {
buttons[i].onclick = function() {
this.disabled = true;
return true;
}
}
}
}
</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test</title>
</head>
<body>
<form name="form1" method="post" action="product_add.asp">
<label for="Name">Name:
<input name="Name" type="text" id="Name">
</label>
<input type="submit" name="submit" id="submit" value="Add">
</form>
</body>
</html>
Can anyone point me in the right direction and show me what I have done
wrong?
Many thanks
James
.
- Prev by Date: Re: Get a keystroke in JScript console app
- Next by Date: window.location.hash in firefox
- Previous by thread: Re: Get a keystroke in JScript console app
- Next by thread: window.location.hash in firefox
- Index(es):
Loading