By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,660 Members | 1,953 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,660 IT Pros & Developers. It's quick & easy.

button in rows

smiley22
P: 54
[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!
Jan 7 '08 #1
Share this Question
Share on Google+
3 Replies


gits
Expert Mod 5K+
P: 5,327
hi ...

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

kind regards
Jan 7 '08 #2

smiley22
P: 54
hi ...

for example: in case your buttons have an id you may identify them through the event.target.id or in IE event.srcElement.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]
Jan 7 '08 #3

gits
Expert Mod 5K+
P: 5,327
:) 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
Jan 7 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.