Announcement

Collapse
No announcement yet.

Javascript/php: help...?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Javascript/php: help...?

    Hello,

    I'm still struggling with my brother's website, ever since MS upgraded IE. As a consequence of that update, the events "OnSubmit" and "Action" are no longer executed at the same time. The first click on the submit button triggers the "OnSubmit", which is a javascript; the second click triggers the "Action", which is a PHP sendmail script.
    Here is what the form looks like:
    Code:
    <form name="form1" onSubmit="CheckMyForm()"  method="post" action="sendmail.php" >
    <table width="100%" border="0" align="center">
    <tr><td width="30%" align="right">Naam:</td>
    	<td align="left"><input type="text" name="naam" id="naam" size="40" maxlength="256" onblur="CheckField('naam')" >
    	 <div class="errormessage" id="e_naam"></div></td></tr>
    ...
    The reason I want to keep the javascript: currently, a field is checked with it, and an error message is displayed in dynamic html (no popups). I would love to keep using this but ever since the IE patch, the first click only runs "CheckMyForm()", a function which simply calls all field-checking functions), the second click executes the post method.

    How can I get these 2 calls back with one click of the submit button?

    Can I call the post-method (sendmail.php) from CheckMyForm() ? If so, how?

    Can I change the onblur event to something that might do the trick? To what?

    I wanted to obmit the call to CheckMyForm (as the user will be directed to an error message using the php script anyway, as he click the submit button), but the function CheckMyForm also sets a variable with the form evaluation ("there were errors", or "there were no errors"). Based on this variable, the PHP script will send the mail, or direct to user to an error message.
    The workaround to this would be to get rid of the variable and duplicate all the errorchecks in the PHP script, but there are quite a lot of them (including date checks, ...) and my PHP knowledge doesn't reach that far. Should I go that route?

    I've been struggling with this for a few months, and can't seem to find a simple solution...


    Jörg
    pixar
    Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

  • #2
    Maybe I've misunderstood your problem, but isn't it just a case of terminating the JS with Return False? The Action will only happen is you dont Return False.
    FT.

    Comment


    • #3
      Nope, that is not the issue...
      I normally return the AND of all the different checks. Just to test it, I tried to return True, and I tried to return False; but it still didn't work.

      First click on submit button: executes the JS
      Second click on submit button: executes the action
      (only in IE)


      Jörg
      pixar
      Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

      Comment


      • #4
        Weird. It does sound like the first click is calling the JS and effectively returning False, and the second click is calling it, running it to completion and returning True then the action is performed.

        I'd suggest you test with an alert box that is displayed no matter what and see if it is displayed on both clicks.

        If you don't get anywhere I can have a look at the code for you...
        FT.

        Comment


        • #5
          The page is part of a content management system, but I'll put the same form on a normal webpage. I'll put it online (most likely Sunday).

          Thanks!


          Jörg
          pixar
          Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

          Comment


          • #6
            Ok, you can find the page here:

            (the calendar doesn't have its stylesheet, and the ok/notok pages are just replacements for the real ones in the cms system)

            It exhibits the same problem, but while making it I may have stumbled on another issue (may be unrelated).
            The page uses 2 connected combo boxes for the hour and minutes (depending on the hour chosen, the minutes are either going from 00 to 55 or from 00 to 25; the pharmacy closes at 12.30 and at 18.30)
            On IE, when selecting the hours, it gives an error message regarding the minutes not being defined yet. When I comment the checkuur function (only have it return true), this error message goes away, but the behaviour is the same:


            I copied the sendmail.php file to sendmail.txt, so you can download it too if necessary:


            It would be a great help to me if you could check out the code...


            Jörg
            Last edited by VJ; 1 October 2006, 07:53.
            pixar
            Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

            Comment


            • #7
              Hi VJ

              The Students came back today so I'm gonna be a little swamped for a few days, but I will look at it asap!

              T.

              /me goes back to Access, pulling hair as he goes
              FT.

              Comment


              • #8
                Yes, our academic year has also just started, so I know difference that makes.

                Thanks in advance though.


                Jörg
                pixar
                Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

                Comment


                • #9
                  Any progress so far..?



                  Jörg
                  pixar
                  Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

                  Comment


                  • #10
                    Sorry mate. That's the third time I've been asked that in the last 30 minutes.

                    I'll do it tonight, probably late.
                    FT.

                    Comment


                    • #11
                      Originally posted by Fat Tone
                      Sorry mate. That's the third time I've been asked that in the last 30 minutes.
                      Really?
                      Makes me wonder who the other two were...

                      I'll do it tonight, probably late.
                      No problem, I was just curious. If you don't have time, you don't have time.


                      Jörg
                      pixar
                      Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

                      Comment


                      • #12
                        One is a PhD student who has already been told she must wait a few weeks and the other is a colleague who's job I've been trying to do all day, and I'm starting now

                        Its 'that time of year'. If I pull the shutters down to all new enguiries, my inbox goes ballistic, so its a constant juggling process. I lost a member of staff just before the start of term, which certainly hasn't helped.

                        Anyway, I said I'll look later tonight, and I promise I will
                        FT.

                        Comment


                        • #13
                          Hi VJ

                          Posting here so people don't think I'm a totally lazy bastard.

                          I think your problems start here:

                          Code:
                                  if (tempbool) { document.getElementById('php_status').value="ok"; }
                                             else { document.getElementById('php_status').value="error"; }
                          
                          	return true;
                          (lines 470-473)

                          Firstly you had return True; and of course True was undefined
                          Second you aren't returning false if tempbool is false, so you want to put that in the if statement.

                          However, I found it would always submit when CheckUur had been called, so the problem lies in there somewhere. Thats about as much as I have the energy for tonight (save to say there are a few HTML errors around 670-685) so we'll have to continue this another time soon. We can take the discussion to pm/email.

                          HTH

                          T.
                          FT.

                          Comment


                          • #14
                            Perhaps we should continue via email?
                            (I'll PM you mine)


                            Jörg
                            pixar
                            Dream as if you'll live forever. Live as if you'll die tomorrow. (James Dean)

                            Comment

                            Working...
                            X