table内 获取同一行 其他列的value

table内  获取同一行 其他列的value

function move(obj,ud){
        var code =  document.getElementById("reportName");
        var year = document.getElementById("reportYear");
        var tr= obj.parentNode.parentNode;            
        var cells = tr.cells;    
        var targetcode = cells[3].childNodes[0].value;
        
        document.getElementById("targetCodeSelect").value = targetcode; //targetCode传参
        if (ud=='1') {//up            
            document.getElementById("upOrDown").value = '1';            
        }
        if(ud=='2'){//down            
            document.getElementById("upOrDown").value = '2';            
        }
        document.getElementById("myform").submit();    
    }
<table width="100%" border="0" cellpadding="0" cellspacing="0" style="border-top:none">
   <tr align="center" class="lantile">
       <th width="36%">指标名称</th>
    <th width="14%">指标代码</th>
    <th width="10%">计量单位</th>
   <th width="10%" colspan="2">操作</th>
 </tr>
  <c:forEach items="${ProList}" var="ral">
  <tr>
    <td align="left" style="text-align: left;"><span title="${ral.targetName}" style="cursor:hand">${ral.targetName}</span></td> 
    <td align="center"><c:if test="${ral.dispIndex<=9}">0${ral.dispIndex}</c:if><c:if test="${ral.dispIndex>9}">${ral.dispIndex}</c:if></td> 
    <td align="center">${ral.targetUnit}</div></td>
    <td stype="display:none;"><input type ="hidden" name="targetCode" id="targetCode" value = "${ral.targetCode}"/> </td>
    <td style="text-align: right;">
        <input type='button' class='moveup' onclick="move(this,'1')" />
        <input type='button' class='movedown' onclick="move(this,'2')" />
    </td>
   </tr>
  </c:forEach>
  
  </table>


通过dom操作  获取tr的childNodes[0].value 即可

原文地址:https://www.cnblogs.com/colmeluna/p/3746134.html