Firing order... why???

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • John Kiernan

    Firing order... why???

    I have a routine in the MouseUp of a 'Save' button on a form. The button is
    a Submit button.

    If I find anything wrong in my routine, I alert the user and return a False.
    If I find nothing, I return a true and things save just fine.

    Except...

    Under certain circumstances, I use a Confirm() dialog box. When I do, even
    when I return a true, the Form does not submit.

    Anyone know why? Thanks in advance!

    -- John Kiernan, KierPro Associates
    Custom VFP/Accounting Programming
    and Web interfaces
    VFP and/or SQL back ends



  • Randy Webb

    #2
    Re: Firing order... why???

    John Kiernan wrote:
    [color=blue]
    > I have a routine in the MouseUp of a 'Save' button on a form. The button is
    > a Submit button.
    >
    > If I find anything wrong in my routine, I alert the user and return a False.
    > If I find nothing, I return a true and things save just fine.
    >
    > Except...
    >
    > Under certain circumstances, I use a Confirm() dialog box. When I do, even
    > when I return a true, the Form does not submit.[/color]

    Sometimes, my light comes on and sometimes it doesn't, can you tell me why?

    The point is, you don't provide enough information to answer you.
    Provide a URL to a simple test case, or post the minimum code to display
    the problem (preferably a URL).

    --
    Randy
    comp.lang.javas cript FAQ - http://jibbering.com/faq

    Comment

    • John Kiernan

      #3
      Re: Firing order... why???

      Sure... here's the code. The last part with the Confirm() is at the bottom.
      If it's really amatuerish (I'm sure it is), please bear with me, I'm on the
      learning curve...
      Thanks for the help!
      -- John

      function cliservsave() {
      lvIsnew = document.getEle mentById('isnew ');
      lvIsnewV = lvIsnew.value
      lvRepf = document.getEle mentById('repfr eq');
      lvRepfV = lvRepf.value;
      lvNotes = document.getEle mentById('NOTES ');
      lvNVal = lvNotes.value;
      lvNotComp = document.getEle mentById('NOTCO MP');
      lvNCVal = lvNotComp.check ed;

      if (lvNVal == "" && lvNCVal == true) {
      alert("If Not Completed, Notes MUST be entered.");
      return false;
      }

      lvDescrip = document.getEle mentById('DESCR IP');
      lvDVal = lvDescrip.value ;
      if (lvDVal == "") {
      alert("Descript ion Cannot be Blank.");
      return false;
      }

      if (lvIsnewV == "true" && lvRepfV !== "None") {
      var lvAnswer='';

      lvAnswer = confirm("Are you sure you want to generate multiple records?")
      if (lvAnswer == false) {
      return false;
      } else {
      return true;
      }
      }

      return true;
      }


      "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
      news:9NOdnevWaa 4oYoLcRVn-sw@comcast.com. ..[color=blue]
      > John Kiernan wrote:
      >[color=green]
      > > I have a routine in the MouseUp of a 'Save' button on a form. The[/color][/color]
      button is[color=blue][color=green]
      > > a Submit button.
      > >
      > > If I find anything wrong in my routine, I alert the user and return a[/color][/color]
      False.[color=blue][color=green]
      > > If I find nothing, I return a true and things save just fine.
      > >
      > > Except...
      > >
      > > Under certain circumstances, I use a Confirm() dialog box. When I do,[/color][/color]
      even[color=blue][color=green]
      > > when I return a true, the Form does not submit.[/color]
      >
      > Sometimes, my light comes on and sometimes it doesn't, can you tell me[/color]
      why?[color=blue]
      >
      > The point is, you don't provide enough information to answer you.
      > Provide a URL to a simple test case, or post the minimum code to display
      > the problem (preferably a URL).
      >
      > --
      > Randy
      > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color]


      Comment

      • Randy Webb

        #4
        Re: Firing order... why???

        John Kiernan wrote:[color=blue]
        > Sure... here's the code. The last part with the Confirm() is at the bottom.
        > If it's really amatuerish (I'm sure it is), please bear with me, I'm on the
        > learning curve...
        > Thanks for the help![/color]

        <--snip-->
        [color=blue]
        > lvAnswer = confirm("Are you sure you want to generate multiple records?")
        > if (lvAnswer == false) {
        > return false;
        > } else {
        > return true;
        > }
        > }[/color]

        Without digging through it, the first thing I noticed was that the above
        could be rewritten as:

        return (confirm("Are you sure....."))

        Since you return the value of lvAnswer, you can simply return lvAnswer,
        which leads to just returning the confirm.

        --
        Randy
        comp.lang.javas cript FAQ - http://jibbering.com/faq

        Comment

        • John Kiernan

          #5
          Re: Firing order... why???

          Dear Randy -
          Thanks... that tip was a good one that saved of lines of code (ironically,
          that's how I'd do it in Visual FoxPro, my main language).

          Now I have this:

          if (lvIsnewV == "true" && lvRepfV !== "None") {

          return confirm("Are you sure you want to generate multiple records?")
          }

          But...

          It still inhibits the Submit, no matter which option on the Confirm is
          chosen.

          Help!

          -- John Kiernan, KierPro Associates
          Custom VFP/Accounting Programming
          and Web interfaces
          VFP and/or SQL back ends


          "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
          news:hN2dnTt5wa oXn73cRVn-oQ@comcast.com. ..[color=blue]
          > John Kiernan wrote:[color=green]
          > > Sure... here's the code. The last part with the Confirm() is at the[/color][/color]
          bottom.[color=blue][color=green]
          > > If it's really amatuerish (I'm sure it is), please bear with me, I'm on[/color][/color]
          the[color=blue][color=green]
          > > learning curve...
          > > Thanks for the help![/color]
          >
          > <--snip-->
          >[color=green]
          > > lvAnswer = confirm("Are you sure you want to generate multiple[/color][/color]
          records?")[color=blue][color=green]
          > > if (lvAnswer == false) {
          > > return false;
          > > } else {
          > > return true;
          > > }
          > > }[/color]
          >
          > Without digging through it, the first thing I noticed was that the above
          > could be rewritten as:
          >
          > return (confirm("Are you sure....."))
          >
          > Since you return the value of lvAnswer, you can simply return lvAnswer,
          > which leads to just returning the confirm.
          >
          > --
          > Randy
          > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color]


          Comment

          • Harag

            #6
            Re: Firing order... why???

            On Mon, 16 Aug 2004 00:32:58 GMT, "John Kiernan"
            <kiernan.je@ver izon.net> wrote:
            [color=blue]
            >Sure... here's the code. The last part with the Confirm() is at the bottom.
            >If it's really amatuerish (I'm sure it is), please bear with me, I'm on the
            >learning curve...
            >Thanks for the help![/color]

            Hope the below helps.

            1st. Rather than putting your validate calling code on the "onmouseup"
            event put it on the "onsubmit" event on the form.

            <form onsubmit="clise rvsave();" method="get">
            <!-- Other input elements here -->
            <input type="submit" value="click me">
            </form>

            [color=blue]
            >-- John
            >
            > function cliservsave() {
            > lvIsnew = document.getEle mentById('isnew ');
            > lvIsnewV = lvIsnew.value
            > lvRepf = document.getEle mentById('repfr eq');
            > lvRepfV = lvRepf.value;
            > lvNotes = document.getEle mentById('NOTES ');
            > lvNVal = lvNotes.value;
            > lvNotComp = document.getEle mentById('NOTCO MP');
            > lvNCVal = lvNotComp.check ed;
            >
            > if (lvNVal == "" && lvNCVal == true) {[/color]

            This can be written as:

            if (!lvNVal && lvNCVal)
            * note the "!" near the beginning.
            [color=blue]
            > alert("If Not Completed, Notes MUST be entered.");
            > return false;
            > }
            >
            > lvDescrip = document.getEle mentById('DESCR IP');
            > lvDVal = lvDescrip.value ;
            > if (lvDVal == "") {[/color]

            again :

            if (!lvDVal) {
            [color=blue]
            > alert("Descript ion Cannot be Blank.");
            > return false;
            > }
            >
            > if (lvIsnewV == "true" && lvRepfV !== "None") {
            > var lvAnswer='';
            >
            > lvAnswer = confirm("Are you sure you want to generate multiple records?")
            > if (lvAnswer == false) {
            > return false;
            > } else {
            > return true;
            > }
            > }[/color]

            see. R.Webs post about the above confirm.
            [color=blue]
            >
            > return true;
            > }
            >
            >[/color]


            HTH

            Al.

            Comment

            • Alberto

              #7
              Re: Firing order... why???

              I haven't time to peruse all the code, yet just a hint: do you have in your
              to be submitted form an onSubmit event handler? That should read :
              <form etc etc onSubmit="retur n functionNameHer e()">

              Do you have in your form tag an action property? Forms to be submitted need
              to specify WHERE they have to be submitted, or they just never get submitted
              no matter what the return value.

              Also, you mention this line
              if (lvIsnewV == "true" && lvRepfV !== "None") {
              return confirm("Are you sure you want to generate multiple records?")

              But in your PREVIOUS code it doesn't include the RETURN statement you
              include above.
              In the code it reads:

              if (lvIsnewV == "true" && lvRepfV !== "None") {
              lvAnswer = confirm("Are you sure you want to generate multiple records?")

              which version are you actually using?

              But as said and maybe more significantly, have you included an action
              property in your FORM tag?

              A mock up example can be:

              <form action="dunno.p hp" onSubmit="retur n foo()">
              <script><!--
              function foo(){
              return confirm("Are you sure you want to generate multiple records?")
              }
              //--></script>
              <input type="submit" value="TEST">
              </form>

              That works in the expected way.

              I hope this helps
              ciao
              Alberto






              "John Kiernan" <kiernan.je@ver izon.net> ha scritto nel messaggio
              news:MMUTc.4786 $Kf4.2625@nwrdd c02.gnilink.net ...
              [color=blue]
              >
              > Now I have this:
              >
              > if (lvIsnewV == "true" && lvRepfV !== "None") {
              >
              > return confirm("Are you sure you want to generate multiple records?")
              > }
              >
              > But...
              >
              > It still inhibits the Submit, no matter which option on the Confirm is
              > chosen.
              >
              > Help!
              >
              > -- John Kiernan, KierPro Associates
              > Custom VFP/Accounting Programming
              > and Web interfaces
              > VFP and/or SQL back ends[/color]


              Comment

              • Denzil

                #8
                Re: Firing order... why???

                Hi,

                Could you also post the "<form..." and the "<input type='submit'.. ." code lines?

                Top of the mind, hope that you do have the following code,
                <input type='submit' value='Save' THE_EVENT='retu rn cliservsave();' >

                HTH.
                Cheerz,
                Denzil

                "John Kiernan" <kiernan.je@ver izon.net> wrote in message news:<_gTTc.145 48$SC1.7472@nwr ddc03.gnilink.n et>...[color=blue]
                > Sure... here's the code. The last part with the Confirm() is at the bottom.
                > If it's really amatuerish (I'm sure it is), please bear with me, I'm on the
                > learning curve...
                > Thanks for the help!
                > -- John
                >
                > function cliservsave() {
                > lvIsnew = document.getEle mentById('isnew ');
                > lvIsnewV = lvIsnew.value
                > lvRepf = document.getEle mentById('repfr eq');
                > lvRepfV = lvRepf.value;
                > lvNotes = document.getEle mentById('NOTES ');
                > lvNVal = lvNotes.value;
                > lvNotComp = document.getEle mentById('NOTCO MP');
                > lvNCVal = lvNotComp.check ed;
                >
                > if (lvNVal == "" && lvNCVal == true) {
                > alert("If Not Completed, Notes MUST be entered.");
                > return false;
                > }
                >
                > lvDescrip = document.getEle mentById('DESCR IP');
                > lvDVal = lvDescrip.value ;
                > if (lvDVal == "") {
                > alert("Descript ion Cannot be Blank.");
                > return false;
                > }
                >
                > if (lvIsnewV == "true" && lvRepfV !== "None") {
                > var lvAnswer='';
                >
                > lvAnswer = confirm("Are you sure you want to generate multiple records?")
                > if (lvAnswer == false) {
                > return false;
                > } else {
                > return true;
                > }
                > }
                >
                > return true;
                > }
                >
                >
                > "Randy Webb" <HikksNotAtHome @aol.com> wrote in message
                > news:9NOdnevWaa 4oYoLcRVn-sw@comcast.com. ..[color=green]
                > > John Kiernan wrote:
                > >[color=darkred]
                > > > I have a routine in the MouseUp of a 'Save' button on a form. The[/color][/color]
                > button is[color=green][color=darkred]
                > > > a Submit button.
                > > >
                > > > If I find anything wrong in my routine, I alert the user and return a[/color][/color]
                > False.[color=green][color=darkred]
                > > > If I find nothing, I return a true and things save just fine.
                > > >
                > > > Except...
                > > >
                > > > Under certain circumstances, I use a Confirm() dialog box. When I do,[/color][/color]
                > even[color=green][color=darkred]
                > > > when I return a true, the Form does not submit.[/color]
                > >
                > > Sometimes, my light comes on and sometimes it doesn't, can you tell me[/color]
                > why?[color=green]
                > >
                > > The point is, you don't provide enough information to answer you.
                > > Provide a URL to a simple test case, or post the minimum code to display
                > > the problem (preferably a URL).
                > >
                > > --
                > > Randy
                > > comp.lang.javas cript FAQ - http://jibbering.com/faq[/color][/color]

                Comment

                Working...