Disabling button double-clicks in the default templates
Survey respondents are often presented the option of logging in to complete surveys. After a respondent enters a user ID and clicks OK, it can sometimes takes a few seconds for the server to authenticate the user credentials. If a respondent clicks OK a second time, the server might generate a message similar to the following:
Thank you for your interest in participating in this survey.
A survey is active for your ID. Please continue the original survey or return in 10 minutes to restart.
You can avoid this by adding the following script to the header tags for all default templates:
<script language="javascript" defer="true">
function addEvent(target, eventName, handlerName)
{
if (target.addEventListener) // W3C
{
target.addEventListener(eventName, handlerName, false);
return true;
}
else if (target.attachEvent) // IE
{
return target.attachEvent("on" + eventName, handlerName);
}
else
{
target["on" + eventName] = handlerName;
}
}
var ctrlNext;
ctrlNext = document.getElementsByName("_NNext")[0];
function NextClicked()
{
if(ctrlNext != null)
{
setTimeout('ctrlNext.disabled = true;', 1);
}
}
addEvent(ctrlNext, 'click', NextClicked);
</script>
The script prevents additional clicks from registering with the server.
See also