button in rows

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • smiley22
    New Member
    • Jun 2007
    • 54

    #1

    button in rows

    [javascript]

    i have a table which add buttons in each row,
    that can dynamically add rows. how will i able to know
    which of the button among the rows are clicked?

    gudluck guys !
    thanks!
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    hi ...

    for example: in case your buttons have an id you may identify them through the event.target.id or in IE event.srcElemen t.id ... during the handling ... that means, when the click-event occurs that event knows which node has fired it ...

    kind regards

    Comment

    • smiley22
      New Member
      • Jun 2007
      • 54

      #3
      Originally posted by gits
      hi ...

      for example: in case your buttons have an id you may identify them through the event.target.id or in IE event.srcElemen t.id ... during the handling ... that means, when the click-event occurs that event knows which node has fired it ...

      kind regards

      [javascript]

      for example if i have 5 rows and 5 buttons in each rows how will it be?


      thanks :)
      [/javascript]

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        :) example:

        [HTML]<html>
        <head>
        <script type="text/javascript">
        function click_handler(e ) {
        var id = e.target ? e.target.id : e.srcElement.id ;
        alert(id);
        }
        </script>
        </head>
        <body>
        <table>
        <tr>
        <td>
        <input type="button" id="b1" value="b1" onclick="click_ handler(event); "/>
        </td>
        </tr>
        <tr>
        <td>
        <input type="button" id="b2" value="b2" onclick="click_ handler(event); "/>
        </td>
        </tr>
        </table>
        </body>
        </html>
        [/HTML]
        kind regards

        Comment

        Working...