I have a javascript table that displays contents from an XML file(that stores letter details), I have at each row a view button which I would like the user to be able to click and it will display the letter details for them. Is this possible?
The javascript I have is:

function showLetter() {
   for (var i=0; i<letters.length; i++) {
      id=letters[i].getAttribute("id");
      title=letters[i].getElementsByTagName("title")[0].childNodes[0].nodeValue;
      sender=letters[i].getElementsByTagName("author")[0].childNodes[0].nodeValue;
      recipient=letters[i].getElementsByTagName("recipient")[0].childNodes[0].nodeValue'
      date=memos[i].getElementsByTagName("date")[0].childNodes[0].nodeValue;
      body=memos[i].getElementsByTagName("body")[0].childNodes[0].nodeValue;
      document.write("<tr><td class='noBox'>"+id+"</td>"+
                         "<td>"+title+"</td>"+
                         "<td class='center'>"+sender+"</td>"+
                          "<td class='center'>"+recipient+"</td>"+
                             "<td class='center'>"+date+"</td>"+
                         "<td class='center'><input type='submit' name='submit' value='remove' onClick='showItem()'></td></tr>");
   }

Easiest way is to pass the id through your function call.

<input type='submit' name='submit' value='remove' onClick='showItem(id)'>

And your function

function showItem(itemID)
{
  //You now have your item's ID so you can pull the required data based on that ID
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.