I would like to code my submit web control button with a timer on it. Its suppose to allow submission until time goes up and the button is disabled from submission. Any directions or tutorials on this?

Recommended Answers

All 3 Replies

easiest way is javascript

<html>
<head>
<script language="JavaScript">
<!--
function setDisableButtonTimer(){
	 disableButtonTimer = setInterval("disableButton()", 5000);

}

function disableButton(){
document.form1.btnSubmit.disabled = true;
clearInterval(disableButtonTimer);
}

-->
</script>

</head>
<body onload="setDisableButtonTimer();">

<FORM ACTION="test.asp" METHOD="POST" name="form1" >
		<SELECT NAME="MyListBox" Size="11" MULTIPLE>
			<OPTION VALUE="0">CustomerID
			<OPTION VALUE="1">CompanyName
			<OPTION VALUE="2">ContactName
			<OPTION VALUE="3">ContactTitle
			<OPTION VALUE="4">Address
			<OPTION VALUE="5">City
			<OPTION VALUE="6">Region
			<OPTION VALUE="7">PostalCode
			<OPTION VALUE="8">Country
			<OPTION VALUE="9">Phone
			<OPTION VALUE="10">Fax
		</SELECT><P>
<INPUT TYPE=submit name="btnSubmit" >&nbsp;&nbsp
<INPUT TYPE=reset>
</FORM>
</body>

</html>
<!--
function setDisableButtonTimer(){
	 disableButtonTimer = setInterval("disableButton()", 5000);

}

function disableButton(){
document.form1.btnSubmit.disabled = true;
clearInterval(disableButtonTimer);
}

-->
</script>

</head>
<body onload="setDisableButtonTimer();">

Campkev, are the above the essential parts i need to have in the html page? Also how do i run the script for the ASP.NET web control button since i have to call 2 functions?

here is a whole web page to give you the idea

<html>
<head>
<script language="JavaScript">
<!--
function setDisableButtonTimer(){
	 disableButtonTimer = setInterval("disableButton()", 5000);

}

function disableButton(){
document.form1.btnSubmit.disabled = true;
clearInterval(disableButtonTimer);
}

-->
</script>

</head>
<body onload="setDisableButtonTimer();">

<FORM ACTION="test.asp" METHOD="POST" name="form1" >
		<SELECT NAME="MyListBox" Size="11" MULTIPLE>
			<OPTION VALUE="0">CustomerID
			<OPTION VALUE="1">CompanyName
			<OPTION VALUE="2">ContactName
			<OPTION VALUE="3">ContactTitle
			<OPTION VALUE="4">Address
			<OPTION VALUE="5">City
			<OPTION VALUE="6">Region
			<OPTION VALUE="7">PostalCode
			<OPTION VALUE="8">Country
			<OPTION VALUE="9">Phone
			<OPTION VALUE="10">Fax
		</SELECT><P>
<INPUT TYPE=submit name="btnSubmit" >&nbsp;&nbsp
<INPUT TYPE=reset>
</FORM>
</body>

</html>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.