Getting which row a user clicked

How do I capture the value of the fields in the row that the user clicks. All my attempts using javascript & JSP give me the same row no matter which one is actually clicked.

Sample code:


function getRowValues( itemClicked )
     // the nodes are used to trace back to row clicked on.
     var grandparent = menuitemClicked.parentNode.parentNode.parentNode.parentNode;
     var rowNode = null;

     // Loop through all the columns in this row to get column values
     for( var intIndex = 0; intIndex < grandparent.childNodes.length; intIndex++ )
        rowNode = grandparent.childNodes[ intIndex ];
        switch ({
            case "fndSymColumn": getFieldValue(rowNode, "hdnFundNumber"); break;

function getFieldValue( rowNode, strField ){
    var hdnNode;
    var hdnValue;

    // Loop through all attributes of the column to get value
    for( var x = 0; x < rowNode.attributes.length; x++ ) {
        if( rowNode.attributes[x].nodeName.toLowerCase() == 'datafld' ) {
           hdnNode = document.getElementById(strField);
           hdnValue = rowNode.attributes[x].nodeValue;
           hdnNode.setAttribute("value", hdnValue);
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Can you post a working example of your problem?  With the HTML you are using?
jkawahAuthor Commented:
I could only give a screen shot to properly illustrate, but I don't know if I'm permitted to do that in this forum. The html goes something like this:

for (int i=rowStarting;i<rowEnding;i++)
        // Display rows of account assets
        count               = count + 1;
        fundSymbol          = acVO.getFundAt(i);

        <tr id="fundInfoRow" class="container1" onmouseover=";" onmouseout=";">
          <td class="fundlist0" onclick="ledgerGo('<%=fundSymbol%>');">
            <b><%=fundSymbol%></b><span class="note">fundSymbol</span><br/>            
          <td id="oltColumn" style="text-align:center;">
            <button id="oltButton" type="button" onMouseover="showmenu(event,linkset[0])"
                onMouseout="delayhidemenu()" class="buttonStyle">
            <div id="popmenu" class="menuskin"
        <tr class="container1" >
              <td class="fundlist0" colspan="9" style="text-align:center;">
                  <form name="transForm" action="<tmpl:prepurl" method="post">
                        <input type="hidden" name="hdnAcctNumber"       value='<%=hdnAcctNumber%>'/>
                      <input type="hidden" name="hdnIndex"            value='<%=i%>'/>
                        <input type="hidden" name="hdnTranType"         />
It seems u always have the same form ("transForm") with the same field names ("hdnAcctNumber", "hdnIndex"...)
No matter which column u choose...

>                 <form name="transForm" action="<tmpl:prepurl" method="post">
>                      <input type="hidden" name="hdnAcctNumber"       value='<%=hdnAcctNumber%>'/>
>                     <input type="hidden" name="hdnIndex"            value='<%=i%>'/>
>                      <input type="hidden" name="hdnTranType"         />
>                </form>

How about use "multibox" and give each field different names:

I am using Struts... My idea is sth like this: Give each field different names in a single "ActionForm"
Then use multibox to get which column the user clicks and retrive the specific field name from the form...
(if u don need multiple options than skip the "multibox" thing)

      <html:form action="/xxx/xxx">
        <c:forEach var="i" begin="rowStarting" end="rowEnding">
            <td><html:multibox property="selectedItems" value="${i}"/></td>
            <td><html:hidden property="hdnAcctNumber${i}" value="${hdnAcctNumber}"/></td>

Sorry that I can only explain it in my own way, but hope the idea helps  :)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jkawahAuthor Commented:
George. Sorry for the late response. I had to find the solution using a workaround. If anyone is interested, I can explain, but it's a bit too detailed. I am not using struts. I will accept your answer so the question gets closed.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.