Submit Your Form In Smart Way
you need to do such things that:
- inform user that data was send for processing
- submit the form
- prevent user from submiting the same data one again
- keep system reponsible for user.
The code bellow do the following when submit button is pressed :
- submit the form to server
- prevent user for pressing sumbit button again (using LaunchSubmit function)
- generate new web page with "Please wait" message (using function msgWait)
- generate button for redirete user to another page when neded (using fumction
goToNotesURL)
The code below is complete web page ready to run.
In Domino you shoud do the following
cerate any form
put java Script code in $$HTMLHead field
create SUBMIT button with the following code :
<I>onClick="launchSubmit(this.form)"</I>
<HTML>
<!-- Lotus-Domino (Release 4.6.3b (Intl -->
<HEAD>
<SCRIPT LANGUAGE="Javascript">
<!--
var submited = false
function launchSubmit(frm)
{
if ( submited == false ) {
frm.submit();
submited = true;
msgWait();
} else {
alert ("Your data was already submited")
}
}
function goToNotesURL (name) // return back to menu define in button
{
var protocol = window.location.protocol;
var host = window.location.host;
var port = window.location.port;
var pathname = window.location.pathname;
var newpath ="";
port != "" ? port= ":" +port : port;
newpath = pathname.slice(0,pathname.indexOf(".nsf")+4);
newpath = newpath +name
alert(newpath);
window.location.replace(newpath);
}
function msgWait() // Wait message during creation of TSE page generator
{
document.open();
document.write("<HTML>");
document.write("<HEAD>");
document.write("<SCRIPT Language='JavaScript'>");
document.write("function goToNotesURL(name)");
document.write("{");
document.write(" var protocol = window.location.protocol; ");
document.write(" var host = window.location.host;");
document.write(" var port = window.location.port;");
document.write(" var pathname = window.location.pathname;");
document.write(" var newpath ='';");
document.write(" port != '' ? port= ':' +port : port;");
document.write(" newpath = pathname.slice(0,pathname.indexOf('.nsf')+4);
");
document.write(" newpath = newpath +'/'+name;");
document.write(" window.location.replace(newpath); ");
document.write(" };");
document.write("</SCRIPT>");
document.write("</HEAD>");
document.writeln("<BODY>");
document.writeln("<CENTER><FONT SIZE=+3 ><B>Please
wait</B></FONT><CENTER>");
document.writeln("Your data was send to processing , you should wait until
processing finish . <BR> ");
document.writeln("You can use this button to run this application");
document.writeln("<BR><CENTER><INPUT TYPE='button' VALUE='Menu'
OnClick=\"goToNotesURL(\'?OpenDatabase\')\" ></CENTER>");
document.writeln("</BODY>");
document.writeln("</HTML>");
document.close();
}
-->
</SCRIPT>
<FORM METHOD=post ACTION="http://127.0.0.1/" NAME="_form1"><BR>
<INPUT NAME="tse_EmpeeID" VALUE="12345678">
<INPUT Type ="Button" NAME="Launch" VALUE="Submit this form"
OnClick="launchSubmit(this.form)" >
</FORM>
</BODY>
</HTML>