how to force click event on disabled submit button

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

    how to force click event on disabled submit button

    Hi all,

    I'm new to these boards and my javascript experience is fairly limited
    and basic so please bear with me. Anyway, on to the question and some
    background. I'm developing using ColdFusion 4.5 and a good deal of the
    page processing depends on whether or not a control is defined. To
    prevent users from clicking on a submit button more than once or
    clicking on another submit button before the page has finished
    processing I have decided to use javascript to disable all of the
    submit buttons on the page. However, this is preventing submission of
    the form. When I try forcing the submit in the function, the
    processing that should occur from clicking the submit button is
    ignored and the submit button is not defined. Here is the code I am
    using the commented code is different things I have tried:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

    <html>
    <head>
    <title>Untitled </title>
    <script language="JavaS cript">
    function fxnDisableBtn(f oo)
    {
    //alert(foo.type + ", " + foo.name + ", " + foo.value);
    //document.frm1.f oo.click();
    //document.frm1.s ubmit();
    document.frm1.b tnSave.disabled = true;
    document.frm1.b tnGoBack.disabl ed = true;
    document.frm1.b tnReturn.disabl ed = true;
    document.frm1.b tnForward.disab led = true;
    //document.frm1.s ubmit();
    //document.frm1.f oo.click();
    switch(foo.name ){
    case "btnSave":
    //alert(foo.type + ", " + foo.name);
    //document.frm1.b tnSave.click();
    foo.click();
    break;
    //document.frm1.b tnSave.click();
    case "btnGoBack" :
    //alert(foo.type + ", " + foo.name);
    document.frm1.b tnGoBack.click( );
    //foo.click();
    break;
    case "btnReturn" :
    //alert(foo.type + ", " + foo.name);
    //document.frm1.b tnReturn.click( );
    break;
    case "btnForward ":
    //alert(foo.type + ", " + foo.name);
    //document.frm1.b tnForward.click ();
    break;
    }
    alert(foo.type + ", " + foo.name + ", " + foo.value + ", " +
    foo.disabled + ", " + foo.click()); //debugging and checking foo
    }
    </script>
    </head>

    <body>
    <form name="frm1" action="#Applic ation.RootPath#/master.cfm?"
    method="post"></form>

    <input type=submit name="btnSave" value="Save (Does Not Forward)"
    onclick="fxnDis ableBtn(btnSave );">
    <br><br>
    <input type=submit name="btnGoBack " value=" <- Back "
    onclick="fxnDis ableBtn(btnGoBa ck);">&nbsp;&nb sp;&nbsp;

    <input type=submit name="btnReturn " value="Return"
    onclick="fxnDis ableBtn(btnRetu rn);">&nbsp;&nb sp;&nbsp;

    <input type=submit name="btnForwar d" value="Forward"
    onclick="fxnDis ableBtn(btnForw ard);">
    <br><br>

    </body>
    </html>
  • HikksNotAtHome

    #2
    Re: how to force click event on disabled submit button

    In article <94aca08d.04010 90753.64bff64d@ posting.google. com>,
    javajonesk@hotm ail.com (JSjones) writes:
    [color=blue]
    >
    >Hi all,
    >
    >I'm new to these boards and my javascript experience is fairly limited
    >and basic so please bear with me. Anyway, on to the question and some
    >background. I'm developing using ColdFusion 4.5 and a good deal of the
    >page processing depends on whether or not a control is defined. To
    >prevent users from clicking on a submit button more than once or
    >clicking on another submit button before the page has finished
    >processing I have decided to use javascript to disable all of the
    >submit buttons on the page. However, this is preventing submission of
    >the form. When I try forcing the submit in the function, the
    >processing that should occur from clicking the submit button is
    >ignored and the submit button is not defined. Here is the code I am
    >using the commented code is different things I have tried:[/color]

    Please format your code for readability.

    Instead of disabling the submit button, set a global variable and check its
    state when the form tries to get submitted:

    var submitForm = true;

    function checkForm(){
    if (submitForm){
    //validation here
    submitForm = false;
    }
    }

    and anytime you need to "freeze" the page (stop the submit from working), set
    submitForm to false, and when finished set it back to true.
    --
    Randy

    Comment

    • Unregistered

      #3
      Re: how to force click event on disabled submit button


      Hi,

      Is there no way to make the form submit after the button is disabled
      I'm having exactly the same problem

      Unregistered
      -----------------------------------------------------------------------
      Posted via http://www.forum4designers.co
      -----------------------------------------------------------------------
      View this thread: http://www.forum4designers.com/message30553.htm

      Comment

      • Michael Winter

        #4
        Re: how to force click event on disabled submit button

        On Tue, 27 Jan 2004 11:52:04 -0600, Unregistered
        <Guest.10pdp5@m ail.forum4desig ners.com> wrote:
        [color=blue]
        > Is there no way to make the form submit after the button is disabled,
        > I'm having exactly the same problem?[/color]

        No, not by clicking the button. Once disabled, it is just that: disabled.
        The button stops receiving events and can't perform any actions, such as
        submission.

        Mike

        --
        Michael Winter
        M.Winter@blueyo nder.co.invalid (replace ".invalid" with ".uk" to reply)

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: how to force click event on disabled submit button

          JSjones wrote:
          [color=blue]
          > I'm new to these boards[/color]

          This is no (bulletin/message) board. You have posted to Usenet,
          via the Google Groups web interface. That interface has its flaws,
          so you better use NetNews client software (a newsreader) instead.
          I recommend not to use Outlook Express, it is mindboggingly buggy.
          [color=blue]
          > I'm developing using ColdFusion 4.5 and a good deal of the
          > page processing depends on whether or not a control is defined. To
          > prevent users from clicking on a submit button more than once or
          > clicking on another submit button before the page has finished
          > processing I have decided to use javascript to disable all of the
          > submit buttons on the page.[/color]

          This is the wrong approach because:
          [color=blue]
          > [...] this is preventing submission of the form[/color]

          You need to revise the concept of your server-side application. It
          must not accept input twice. Sessions are a good way to accomplish that.
          [color=blue]
          > <script language="JavaS cript">[/color]

          <script type="text/javascript">
          [color=blue]
          > function fxnDisableBtn(f oo)
          > {
          > //alert(foo.type + ", " + foo.name + ", " + foo.value);
          > //document.frm1.f oo.click();[/color]

          No. If you have a method that accesses forms, pass a
          reference the HTMLFormElement object instead ("this.form"
          in an event handler of a form control, "this" in an event
          handler of the "form" element). This avoids code like
          [color=blue]
          > //document.frm1.s ubmit();
          > document.frm1.b tnSave.disabled = true;
          > document.frm1.b tnGoBack.disabl ed = true;
          > document.frm1.b tnReturn.disabl ed = true;
          > document.frm1.b tnForward.disab led = true;
          > //document.frm1.s ubmit();
          > //document.frm1.f oo.click();[/color]

          and you could use

          ... foo.elements['btnSave'] ...

          aso. instead. And remember not to make operation dependent on
          client-side script support for it can be disabled or not even
          present.


          HTH

          PointedEars

          Comment

          • Thomas 'PointedEars' Lahn

            #6
            Re: how to force click event on disabled submit button

            Unregistered wrote:
            [color=blue]
            > Is there no way to make the form submit after the button is disabled,[/color]

            No, there is not.
            [color=blue]
            > I'm having exactly the same problem?[/color]

            I do not know. Have you?


            PointedEars

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: how to force click event on disabled submit button

              Unregistered wrote:
              [color=blue]
              > Is there no way to make the form submit after the button is disabled,[/color]

              No, there is not.
              [color=blue]
              > I'm having exactly the same problem?[/color]

              I do not know. Are you having it?


              PointedEars

              Comment

              Working...