Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 25
  1. #1
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation Which submit button was clicked?

    I have three submit buttons on my form right.....

    in the form I have onSubmit="return validate()"

    How do i found out in the validate function which submit button was clicked?

  • #2
    Senior Coder A1ien51's Avatar
    Join Date
    Jun 2002
    Location
    Between DC and Baltimore In a Cave
    Posts
    2,717
    Thanks
    1
    Thanked 94 Times in 88 Posts
    try looking into

    event.srcElement

    that may help

    Eric

  • #3
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Okay.... i could've tried that but is there any other form method that I can use? I wanna use a form method.... really don't wanna get my hands soaked into those cross browser issues, so I really wanna know if there is a form collection object or something of the sort I could check to which button was clicked


    thanks tho!

  • #4
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    Ok, whats gonna happen when you find out which one is clicked? And can't you just validate the whole form with one submit button? can you explain a little more?

  • #5
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    don't use a submit button, use two different buttons that have an onclick. then have the onclick event handle whatever it is you're trying to do.

  • #6
    Regular Coder
    Join Date
    Dec 2004
    Location
    Jamaica
    Posts
    592
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Okay, i've got an email inbox right.
    Its got a delete button and a forward button for starters.... They are both submit buttons

    What I wanna do is that the user is prompted if he/she hits the delete button and no messages are selected (stop the submission of the form) and the user is also prompted if he/she tries to use the forward button and no or more than one messages are selected.

    So I have been using the a form validation function to stop the form submission.

    Hey if u wanna c the actual thing, plz send me a PM

    All help is greatly appreciated

  • #7
    fci
    fci is offline
    Senior Coder
    Join Date
    Aug 2004
    Location
    Twin Cities
    Posts
    1,345
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just post the HTML + JS.

  • #8
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by fci
    don't use a submit button, use two different buttons that have an onclick. then have the onclick event handle whatever it is you're trying to do.
    no, because that relies on JS for form submission which is hardly accessible for non-JS browsers.
    *keep it simple (TM)

  • #9
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Have a global variable that gets updated accordingly when one of the submit butttons is clicked.

    var mode = 0; //0=delete, 1=forward

    Then in the submit buttons:

    <input type="submit" value="Delete" onclick="mode=0" />
    <input type="submit" value="Forward" onclick="mode=1" />

    Then in the validate function, check the value of the mode variable and do the appropriate action.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #10
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by jaywhy13
    I have three submit buttons on my form
    Why is that?

  • #11
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Sayonara
    Why is that?
    There's nothing wrong in having multiple submit buttons in a form. REad this thread.

    http://www.codingforums.com/showthread.php?t=30244
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #12
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by glenngv
    There's nothing wrong in having multiple submit buttons in a form. REad this thread.

    http://www.codingforums.com/showthread.php?t=30244
    I'm well aware that you can have multiple submit buttons - what I am not aware of is how they are being implemented in jaywhy13's form, because I am not telepathic.

  • #13
    Senior Coder
    Join Date
    Feb 2004
    Location
    Edinburgh
    Posts
    1,352
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Sayonara
    I am not telepathic.
    noooo?? ... and that's why you use the forum Sherlock
    *keep it simple (TM)

  • #14
    Regular Coder
    Join Date
    Oct 2004
    Posts
    256
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well quite.

  • #15
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,075
    Thanks
    0
    Thanked 256 Times in 252 Posts
    Quote Originally Posted by Sayonara
    I'm well aware that you can have multiple submit buttons - what I am not aware of is how they are being implemented in jaywhy13's form, because I am not telepathic.
    He described it in his 3rd post.
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •