www.webdeveloper.com
Results 1 to 3 of 3

Thread: [RESOLVED] how to know the name of button

  1. #1
    Join Date
    Nov 2009
    Posts
    23

    resolved [RESOLVED] how to know the name of button

    Hello,

    Is there any way to know which button has called javascript function?

    for example;
    i've 4 buttons.
    Plus, Minus, Divide & Multiply

    and hv one function calc() to calculate.
    in calc() i want to know from which button this function has been called so related IF condition can trigger.

    I'm sorry for being stupid

    Thanks

  2. #2
    Join Date
    Sep 2009
    Posts
    52
    Pass the button to your calc function eg.
    PHP Code:
    <script>
    function 
    calc(btn) {
      
    alert(btn.name);
    }
    </script>

    <input type="button" name="btnA" value="A" onclick="calc(this);">
    <input type="button" name="btnB" value="B" onclick="calc(this);"> 

  3. #3
    Join Date
    Nov 2009
    Posts
    23
    Great help.
    I've learn't a lot on this forum from you guys.

    Ans rating: *****

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles