submit button - onClick function is not completed to the end

Discussion in 'Javascript' started by despo, Feb 3, 2010.

  1. despo

    despo Guest

    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?
     
    despo, Feb 3, 2010
    #1
    1. Advertising

  2. despo wrote:

    > 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
    --
    Use any version of Microsoft Frontpage to create your site.
    (This won't prevent people from viewing your source, but no one
    will want to steal it.)
    -- from <http://www.vortex-webdesign.com/help/hidesource.htm> (404-comp.)
     
    Thomas 'PointedEars' Lahn, Feb 3, 2010
    #2
    1. Advertising

  3. despo

    despo Guest

    I am sorry that I was not clear.
     
    despo, Feb 5, 2010
    #3
  4. despo

    Scott Sauyet Guest

    On Feb 5, 5:29 am, despo <> wrote:
    > 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
     
    Scott Sauyet, Feb 5, 2010
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Bill Cunningham

    completed function

    Bill Cunningham, Feb 25, 2011, in forum: C Programming
    Replies:
    13
    Views:
    498
    Barry Schwarz
    Feb 26, 2011
  2. Guest
    Replies:
    2
    Views:
    1,630
    Guest
    Oct 25, 2004
  3. Ria Van Heerden
    Replies:
    1
    Views:
    151
    David Dorward
    Jul 20, 2005
  4. Replies:
    2
    Views:
    269
  5. Dr. Leff
    Replies:
    7
    Views:
    230
Loading...

Share This Page