Hi all!
What about a one-time submit feature for the formulars in OTRS? Here's
an easy javascript way:
In the <head> of Header.dtl, set:
<script language="JavaScript">
<!--
var UserSubmits=0;
function oneSubmit(Element,Value){
if (UserSubmits!=0) return false;
if (Element) with (Element)
{ value=Value; disabled=true; }
/* insert more code here */
UserSubmits++; return true;
}
//-->
</script>
Each form you would like to protect from double submits must bear an
attribute 'onSubmit':
<form
method="get"
action="$Env{"CGIHandle"}"
onSubmit='return oneSubmit(this.submitter,'Please wait...');'
>
You see, there has to be a 'this.submitter', which could be s.th like:
<input
name="submitter"
class="button"
type="submit"
value="$Text{"Move"}"
>
Surely one can argue about the necessity of changing the button's text.
It's nothing more than user-friendlyness, as the code prevents
submitting a form a second time even if the button isn't used, but the
RETURN key from inside an <input> field, f.e.
The trick, if any, is the javascript code checking for the value of
UserSubmits, which counts the times the user has submit the form - who'd
have thought that? One could do more with this value, such as displaying
an intermittent page to teach the agent, or similar. You get it.
Another approach were to not only to substitute the submit button's
text, but to also display a huge warning, like this:
[...we are in <head>...]
<script language="JavaScript"><!--
var UserSubmits=0;
function oneSubmit(Element,Value){
if (UserSubmits!=0) return false;
document.getElementById("Warner").style='inline';
UserSubmits++;
return true;
}
//--></script>
<dtl set $Env{"Warner"} = "<div id='Warner' class='warner'>$Text{"Your
request is being processed, please wait."}</div>">
<style type="text/css">
<!--
.warner {
position: absolute;
left: 25%;
top: 25%;
// width: 50%;
// height: 50%;
border: 0.5ex solid #FF0000;
color: darkred;
background-color: white;
font-size: 3em;
text-align: center;
vertical-align: middle;
padding: 1em;
z-index: 1000;
display: none;
}
-->
</style>
</head>
<a name="top"></a>
<body>
$Env{"Warner"}
[...]
Feel free to experiment with the arguments, esp. with 'left', 'top',
'width' and 'height'. Their meaning depends on where in the code you
place them.
Comments welcome.
Feel good,
Robert Kehl
--
Entweder ich gehe links vorbei, oder ich gehe rechts vorbei.
Ludwig Kögl