I need to place a second submit button on a page with a web grid form for WAS ver 9. The first is the standard grid submit button and the target page is <self>. The second submit button is to submit the form with validation like the standard button but then to redirect to a different page. This has been discussed several times in these forums with significant contributions from Steve Wood, Steve Workings, Martin Horzempa and others (see thread: mimic a dialog submit using OnClick). The simulated button click and redirection can be done with javascript functions but most who tried reported that the actual update of the data failed. I have done several experiments and found at the suggestion of Jerry Brightbill (see thread: submitting a form � redux) that timing of the two processes is critical. I have been able to find a solution with a delay between the two processes. The standard grid component is placed on an a5w page. The top of the page includes the code (taken from http://dev-notes.com or another version from www.sean.co.uk):
<html>
<head>
<script language="javascript">
function pause(milliseconds) {
var dt = new Date();
while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}
</script>
Continue with the head, body etc
And on the page source I included the second button with the code (modified from Steve Workings):
<p>
<input align="right" type="button" class="button-standard" value="test submit >>>"
onClick="document.forms[0].test_Button_Submit.click();pause(2000);window.location =
'mytarget.a5w'">
</p>
The form name was �test� and the form submit button name was �test_Button_Submit� as I found by reading the source code from a page sent to IE by the AS. My addition was to call pause(2000) between the button click and the redirect. My experiments showed that without a pause the redirection occurs before the submit can update the data. Using the localhost I found that a delay of at least 500 milliseconds is required and delays of more then 5000 milliseconds produces an error message from IE. I settled on 2000 milliseconds with reliable results. I have not tested this on a remote server with extensive validation and look forward to others testing and hearing their results.
I now have one submit button save the data and return to the same form while the other submit button saves the data and takes the user to a different screen such as a menu. I also include a reset button and sometimes an �exit without save� button which is a simple redirection. As a note the standard javascript setTimeout() does not actually pause the routine and does not work here.
I have found this forum extremely useful and thank so many of you for sharing your insights.
<html>
<head>
<script language="javascript">
function pause(milliseconds) {
var dt = new Date();
while ((new Date()) - dt <= milliseconds) { /* Do nothing */ }
}
</script>
Continue with the head, body etc
And on the page source I included the second button with the code (modified from Steve Workings):
<p>
<input align="right" type="button" class="button-standard" value="test submit >>>"
onClick="document.forms[0].test_Button_Submit.click();pause(2000);window.location =
'mytarget.a5w'">
</p>
The form name was �test� and the form submit button name was �test_Button_Submit� as I found by reading the source code from a page sent to IE by the AS. My addition was to call pause(2000) between the button click and the redirect. My experiments showed that without a pause the redirection occurs before the submit can update the data. Using the localhost I found that a delay of at least 500 milliseconds is required and delays of more then 5000 milliseconds produces an error message from IE. I settled on 2000 milliseconds with reliable results. I have not tested this on a remote server with extensive validation and look forward to others testing and hearing their results.
I now have one submit button save the data and return to the same form while the other submit button saves the data and takes the user to a different screen such as a menu. I also include a reset button and sometimes an �exit without save� button which is a simple redirection. As a note the standard javascript setTimeout() does not actually pause the routine and does not work here.
I have found this forum extremely useful and thank so many of you for sharing your insights.
Comment