disabling a html form button...

Status
Not open for further replies.

E3

Ars Centurion
387
<script type="text/javascript">
function countclicks()
{
Session("count")=Session("count")+1
}
</script>
</head>


<form name="form1" method="post" action="Example1a.Asp">
<% if Session("count")= "3" Then
call disablebutton
else
call displaybutton
end if
%>

<% sub displaybutton %>
<input type="submit" name="Upload" value="UpLoad" >
<% end sub %>

<% sub disablebutton %>
<input type="submit" name="Upload" value="UpLoad" disabled >
<% end sub %>
</form>


I m trying to disable a button after it has been click 3 times.

However IE gives me a vague error that I can't seem to find whats wrong, any idea?

Error Type:
Microsoft VBScript compilation (0x800A03EA)
Syntax error
/demo/Add_Bid_Items3.asp, line 179
sub displaybutton


line 179 --> this line <% sub displaybutton %>
 

blazko

Ars Scholae Palatinae
840
Hmm... I'm pretty sure that is completely wrong.

Try this:

<code>

<script language="javascript">
var clicks = 0;

function click() {
//Do whatever the button does
++clicks;

if(clicks >= 3) {
document.form1.Upload.disabled = !document.form1.Upload.disabled;
}
}
< / script >

...

< form name="form1" method="post" action="Example1.asp" >
< input type="submit" name="Upload" value="Upload" disabled onclick="click[]"> //change the brackets to paren's the forum isn't liking paren's for some reason..
</form>

</code>


Edit: omfg code tag sucks. It was actually drawing a button in my post!
 
Status
Not open for further replies.