How to figure out on which row of a table I click e.g. a checkbox

Discussion in 'HTML' started by Stefan Mueller, Jan 23, 2006.

  1. <form name = "my_form" action = "" method = "post" accept-charset =
    "iso-8859-1">
    <table name = "my_table" border = "1">
    <tr>
    <td>
    <input type = "checkbox" onClick = "alert('Row 1');">
    </td>
    </tr>
    <tr>
    <td>
    <input type = "checkbox" onClick = "alert('Row 2');">
    </td>
    </tr>
    </table>
    </form>

    That works fine but I'd like to do it dynamically.

    I tried
    alert(document.my_form.my_table.row);
    but it doesn't work (Error: document.my_form.my_table has no properties). I
    think the problem is that <table> does not have a 'name' attribute.

    Does anyone know how I can get the row dynamically?
    Stefan
     
    Stefan Mueller, Jan 23, 2006
    #1
    1. Advertising

  2. Stefan Mueller wrote:
    > Does anyone know how I can get the row dynamically?


    What is it you are "really" trying to accomplish? No one cares about
    the row where you clicked. What are your "really" trying to do? Why
    do you think you need the row?
     
    Travis Newbury, Jan 23, 2006
    #2
    1. Advertising

  3. >> Does anyone know how I can get the row dynamically?
    >
    > What is it you are "really" trying to accomplish? No one cares about
    > the row where you clicked. What are your "really" trying to do? Why
    > do you think you need the row?


    I wrote some Java Scripts to sort a html table.
    The data are visible on the screen (html table) and are also stored in an
    array. If I click now on a checkbox I need to now which row of my array
    'array[row]' I have to modify (modify the flag of the checkbox). That's the
    reason I need to know on which row I've clicked the checkbox.

    Stefan
     
    Stefan Mueller, Jan 23, 2006
    #3
    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. =?Utf-8?B?UmljaGFyZEg=?=

    Checkbox and dropdownlist row in repeater row

    =?Utf-8?B?UmljaGFyZEg=?=, Mar 23, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    6,392
    =?Utf-8?B?UmljaGFyZEg=?=
    Mar 24, 2006
  2. phl
    Replies:
    1
    Views:
    4,375
    Martin Jay
    Jun 8, 2006
  3. dave

    stumped...table - row - click event, cancel checkbox event

    dave, Sep 2, 2006, in forum: ASP .Net Building Controls
    Replies:
    0
    Views:
    231
  4. Jack
    Replies:
    3
    Views:
    140
    Bob Barrows [MVP]
    Jan 4, 2006
  5. Stefan Mueller
    Replies:
    4
    Views:
    132
    Stefan Mueller
    Jan 26, 2006
Loading...

Share This Page