Wed, 31 Dec 2014 07:53:36 +0100
Correct small whitespace inconsistency, lost while renaming variables.
1 <html>
2 <!-- This Source Code Form is subject to the terms of the Mozilla Public
3 - License, v. 2.0. If a copy of the MPL was not distributed with this
4 - file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
5 <head>
6 <title>Form to sign</title>
7 <script language="javascript">
8 <!--
9 function submitSigned(form){
10 var signature = "";
11 var dataToSign = "";
12 var i;
14 form.action='cgi-bin/signedForm.pl';
15 for (i = 0; i < form.length; i++)
16 if (form.elements[i].type == "text")
17 dataToSign += form.elements[i].value;
19 // alert("Data to sign:\n" + dataToSign);
20 signature = crypto.signText(dataToSign, "ask");
21 /* alert("You cannot see this alert");
22 alert("Data signature:\n" + signature); */
24 if (signature != "error:userCancel") {
25 for (i = 0; i < form.length; i++) {
26 if (form.elements[i].type == "hidden") {
27 if (form.elements[i].name == "dataToSign")
28 form.elements[i].value = dataToSign;
29 if (form.elements[i].name == "dataSignature")
30 form.elements[i].value = signature;
31 }
32 }
33 form.submit();
34 }
35 }
36 //-->
37 </script>
38 </head>
40 <body>
41 <form method=post Action="cgi-bin/form.pl">
42 <input type=hidden size=30 name=dataSignature>
43 <input type=hidden size=30 name=dataToSign>
44 <input type=text size=30 name=p>
45 <BR>
46 <input type=text size=30 name=q>
47 <BR>
48 <input type=text size=30 name=r>
49 <BR>
50 <input type=submit value="Submit Data">
51 <input type=button value="Sign and Submit Data" onclick=submitSigned(this.form)>
52 <input type=reset value=Reset>
53 </form>
54 </body>
55 </html>