submit button - onClick function is not completed to the end

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?
 
T

Thomas 'PointedEars' Lahn

despo said:
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",

1. Post the generated code next time, without prefixed line numbers
(since those are the line numbers of the generating code, which
obviously is not JS/ES, they do not matter here anyway).

2. Use the `onsubmit' attribute of the `form' element, not the
`onclick' attribute of the submit button.
The function is called and starts working in a fine way, but it stays
there. [...]

That is a useless error report. Read the FAQ before posting here again.

<http://jibbering.com/faq/#posting>


PointedEars
 
S

Scott Sauyet

I am sorry that I was not clear.

Whether it sounded that way or not, Thomas' response is an invitation
to post a more explicit description of the problem. As Thomas pointed
out, this is not enough for us to offer any suggestions: "The function
is called and starts working in a fine way, but it stay there." Can
you be more descriptive, and show us not the Perl but the JS that's
generated and any relevant HTML?

-- Scott
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,742
Latest member
AshliMayer

Latest Threads

Top