detecting submit control in Javascript

Discussion in 'Javascript' started by wardy, Jan 19, 2007.

  1. wardy

    wardy Guest

    Hi all,

    Looking for a bit of help with this one...I have a situation where I
    need to be able to determine the control that initiated a form's submit
    action in client-side Javascript. I am currently calling a Javascript
    function on the client-click that returns true/false to control the
    submission of a product, but I am now trying to implement functionality
    to disable the buttons after the initial click, but continue with the
    submit operations. My form is a mixture of HTML and .NET controls, so
    I'm wondering if there is a generic way to determine in Javascript what
    control actually caused my validation function to be invoked, short of
    having to pass the control as part of the argument list - I am trying
    to get a generic solution not requiring that level of modification.

    Of note here is that as soon as I disable a button, the postback event
    doesn't fire anymore, so I'm having to manually invoke this postback in
    Javascript, and this is why I need the control that initiated the
    submit, as I must invoke it's postback routine.

    Thanks,

    wardy
    wardy, Jan 19, 2007
    #1
    1. Advertising

  2. wardy

    ASM Guest

    wardy a écrit :
    > Hi all,
    >
    > Looking for a bit of help with this one...I have a situation where I
    > need to be able to determine the control that initiated a form's submit
    > action in client-side Javascript.


    <form action="my.asp" blah >
    <input ... >
    <input type=submit name=send value="action 1">
    <input ... >
    <input ...>
    <input type=submit name=send value="action 2">
    <select ...
    <input type=submit name=send value="action 3">
    <input type=submit name=send value="action 4">
    </form>

    then on submit you asp receive witch action has been fired

    send=action x



    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Jan 19, 2007
    #2
    1. Advertising

  3. wardy

    ASM Guest

    wardy a écrit :
    > Hi all,
    >
    > I am currently calling a Javascript
    > function on the client-click that returns true/false to control the
    > submission of a product, but I am now trying to implement functionality
    > to disable the buttons after the initial click, but continue with the
    > submit operations.


    <script type="text/javascript">
    var act = '';
    var send = [];
    function sd(what) {
    act = what.value;
    send[send.length] = act;
    what.disabled = (act!='Submit');
    }
    </script>
    <form action="test.htm" onsubmit="return (act =='Submit');">
    ..../...
    <input type=submit name=send onclick="sd(this);" value="action 1">
    <input type=submit name=send onclick="sd(this);" value="action 2">
    <input type=submit name=send onclick="sd(this);" value="action 3">
    <input type=submit name=send onclick="sd(this);" value="action 4">
    <input type=submit onclick="sd(this);" value="Submit">
    </form>
    <a href="javascript:alert(send);">what was validated ?</a>

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Jan 19, 2007
    #3
  4. wardy

    ASM Guest

    ASM a écrit :

    <script type="text/javascript">
    var act = '';
    var send = [];
    function sd(what) {
    act = what.value;
    if(act!='Submit') {
    send[send.length] = act;
    what.disabled = true;
    }
    }
    </script>

    --
    Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    Stephane Moriaux and his (less) old Mac already out of date
    ASM, Jan 19, 2007
    #4
  5. wardy

    wardy Guest

    Hi ASM,

    Thanks for the reply....is there not any way to determine the
    submission control without having to put the value attribute on the
    controls? I was hoping for a manner that would not require any
    additional coding to get this, simply due to the dynamic nature of my
    application.

    Thanks,

    JohnW

    ASM wrote:
    > ASM a écrit :
    >
    > <script type="text/javascript">
    > var act = '';
    > var send = [];
    > function sd(what) {
    > act = what.value;
    > if(act!='Submit') {
    > send[send.length] = act;
    > what.disabled = true;
    > }
    > }
    > </script>
    >
    > --
    > Stephane Moriaux et son (moins) vieux Mac déjà dépassé
    > Stephane Moriaux and his (less) old Mac already out of date
    wardy, Jan 23, 2007
    #5
    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. Mark
    Replies:
    1
    Views:
    1,662
  2. Halldór Ísak Gylfason

    detecting when a frame has loaded the result of a form submit

    Halldór Ísak Gylfason, Sep 15, 2003, in forum: Javascript
    Replies:
    2
    Views:
    398
    asdf asdf
    Sep 15, 2003
  3. Joop
    Replies:
    5
    Views:
    569
  4. ljlolel
    Replies:
    2
    Views:
    492
  5. jatrojoomla
    Replies:
    1
    Views:
    162
Loading...

Share This Page