5
rated 0 times
[
10]
[
5]
/ answers: 1 / hits: 64208
/ 13 Years ago, thu, october 20, 2011, 12:00:00
Im very new to html and javascript.
I want to get the content of element whenever the user click on a table row using javascript.
test.html
<html>
<head>
<script text=text/javascript>
function dispTblContents() {
var pName = document.getElementById(pName).value;
var pAddress = document.getElementById(pAddress).value;
var pEmail = document.getElementById(pEmail).value;
alert(pName + + pAddress + + pEmail);
}
</script>
</head>
<body>
<table>
<thead>
<tr>
<th>Name</th>
<th>Address </th>
<th>Email</th>
</tr>
</thead>
<tbody>
<tr onclick=dispTblContents(); >
<td id=pName>Ricardo Lucero</td>
<td id=pAddress>Mexico City, Mexico</td>
<td id=pEmail>[email protected]</td>
</tr>
</tbody>
</table>
</body>
</html>
Whenever I click the row it displays undefined undefined undefined
. I know my code is wrong but I really don't how to fix this. Can somebody please help me. Im very new to this thing. Thanks in advance.
More From » html