D
despo
Hi
I use the following function checkform2(maxlines), in order to verify
some of the elements set in a form before submission via a submit
button, defined as follows. The html file is written by a perl script.
(numbers in the beginning of each line are the line numbers, and I
include them in order to make it easier to navigate for whoever gives
me a clue).
305 "<input type='submit' value='submit' style='width:60pt'",
306 # this does not work...
307 " onClick='checkform2(",$#Vallist,")'></td></tr>\n",
107 function checkform2(maxlines){
108 var j, depth=0;
109 var result = '';
110 // line by line scanning
111 for (j=0; j<=maxlines; j++) {
112 // check loops
113 confirm("point 0" + j);
114 if (document.getElementsByName('stl' + line)[0].checked ===
true) {
115 depth++;
116 }
117 confirm("point 1" + j);
118 if (document.getElementsByName('edl' + line)[0].checked ===
true) {
119 depth--;
120 }
121 if (document.getElementsByName('cck' + j)[0].value != depth ){
122 result = result +
123 'textbox=' + document.getElementsByName('cck' + j)
[0].value +
124 'does not match the calculated loop depth (' + depth + ')'
+
125 ' + CORRECTED\n';
126 document.getElementsByName('cck' + j)[0].value = depth;
127 }
128 }
129 // finally all loops have to closed
130 if (document.getElementsByName('cck' + maxlines)[0].value != 0)
{
131 result = result + 'beginnings of loops do not match loop
endings' +
132 ' + TO BE CORRECTED BY USER\n';
133 }
134
135 if (result != '') confirm(result);
136 }
The function is called and starts working in a fine way, but it stays
there. From the confirm boxes from lines 113 and 117 that are supposed
to pop-up, only the first one appears when there is a problem in the
form validation, and only one time (not through all iterations of the
for construct). The form is submitted without ever being interrupted,
except from this one confirm box.
I cannot understand for which reason this happens. Does anybody see
any mistake in my code?
I use the following function checkform2(maxlines), in order to verify
some of the elements set in a form before submission via a submit
button, defined as follows. The html file is written by a perl script.
(numbers in the beginning of each line are the line numbers, and I
include them in order to make it easier to navigate for whoever gives
me a clue).
305 "<input type='submit' value='submit' style='width:60pt'",
306 # this does not work...
307 " onClick='checkform2(",$#Vallist,")'></td></tr>\n",
107 function checkform2(maxlines){
108 var j, depth=0;
109 var result = '';
110 // line by line scanning
111 for (j=0; j<=maxlines; j++) {
112 // check loops
113 confirm("point 0" + j);
114 if (document.getElementsByName('stl' + line)[0].checked ===
true) {
115 depth++;
116 }
117 confirm("point 1" + j);
118 if (document.getElementsByName('edl' + line)[0].checked ===
true) {
119 depth--;
120 }
121 if (document.getElementsByName('cck' + j)[0].value != depth ){
122 result = result +
123 'textbox=' + document.getElementsByName('cck' + j)
[0].value +
124 'does not match the calculated loop depth (' + depth + ')'
+
125 ' + CORRECTED\n';
126 document.getElementsByName('cck' + j)[0].value = depth;
127 }
128 }
129 // finally all loops have to closed
130 if (document.getElementsByName('cck' + maxlines)[0].value != 0)
{
131 result = result + 'beginnings of loops do not match loop
endings' +
132 ' + TO BE CORRECTED BY USER\n';
133 }
134
135 if (result != '') confirm(result);
136 }
The function is called and starts working in a fine way, but it stays
there. From the confirm boxes from lines 113 and 117 that are supposed
to pop-up, only the first one appears when there is a problem in the
form validation, and only one time (not through all iterations of the
for construct). The form is submitted without ever being interrupted,
except from this one confirm box.
I cannot understand for which reason this happens. Does anybody see
any mistake in my code?