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

S

Stefan Mueller

<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
 
T

Travis Newbury

Stefan said:
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?
 
S

Stefan Mueller

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,236
Members
46,825
Latest member
VernonQuy6

Latest Threads

Top