Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6716967
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T08:47:49+00:00 2026-05-26T08:47:49+00:00

Im very new to html and javascript. I want to get the content of

  • 0

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">rlucero@test.com</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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T08:47:49+00:00Added an answer on May 26, 2026 at 8:47 am

    You need innerHTML not value here, value is used for form elements.

    <script text="text/javascript">
    function dispTblContents() {
     var pName = document.getElementById("pName").innerHTML;
     var pAddress = document.getElementById("pAddress").innerHTML;
     var pEmail = document.getElementById("pEmail").innerHTML;
    
     alert(pName + " " + pAddress + " " + pEmail);
    }
    </script>
    

    You might also want to look into jQuery if you’re not using it yet, it makes selecting and manipulating HTML with Javascript a lot easier.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm very new with Javascript. I'm trying to do something with Show/Hide functions. html:
I am very new to MVC. I've been learning to use plain HTML or
I'm VERY confused as to why this code Html.ActionLink(About, About, Home, new { hidefocus
I still very new using Subversion. Is it possible to have a working copy
I'm very new at CSS and i want to put a header on to
I am very new to Javascript and Jquery, so my apologies for this beginner's
I'm very new to javascript (started messing with it today). I'm trying to change
I'm very new to JQuery and don't have much experience with javascript at all,
Maybe this is a very silly question but I'm new using django. I have
I'm trying to do very basic, custom animation with JavaScript. I'm using a library

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.