SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    getting the name of the submit button using js

    <form name="f1" method="post" onsubmit="get_button()">

    <input type="submit" name="s1" value="s1">
    <input type="submit" name="s2" value="s2">
    <input type="submit" name="s3" value="s3">

    </form>

    on submit I want to know which submit button I clicked. How to get it.

  2. #2
    SitePoint Wizard silver trophy
    Join Date
    Mar 2006
    Posts
    6,132
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    think you should have your thread moved to the javascript forum, because this is not related to php.

  3. #3
    SitePoint Evangelist dscriptor's Avatar
    Join Date
    Oct 2005
    Location
    in front of my computer
    Posts
    571
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can search about getElementByID in Google.
    happy is the man that finds wisdom....wisdom in {PHP}.


  4. #4
    SitePoint Wizard bronze trophy Kailash Badu's Avatar
    Join Date
    Nov 2005
    Posts
    2,560
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wouldn't something like this work:

    Code:
    document.forms['frmName'].elements['submit'].value

  5. #5
    SitePoint Addict
    Join Date
    Jun 2006
    Posts
    220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    alert(document.forms["f1"].elements["submit"].value);

    I am getting an alert msg of "undefined"


Bookmarks

Posting Permissions

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