Retrieve data from a row in a table

1

I have this table in a JSP and I'm trying to get all the values from the row by clicking the button with JavaScript.

<table id="myTable">
<c:if test="${not empty conversaciones}">
   <tr class="titulo">
     <th>Id Conversacion</th>
     <th>Inicio conversacion</th>
     <th>Nombre agente</th>
     <th>Nombre cola origen</th>
     <th>ID cola origen</th>
     <th>Nombre cliente</th>
     <th>Email cliente</th>
     <th>Asunto email</th>
     <th>ID cola aparcamiento participante</th>
     <th></th>
   </tr>

<c:forEach items="${conversaciones}" var="conversacion">

<tr class="fila" onclick="myFunction(this)">
     <td><a href="javascript:;" id="enlaceEnviar"><c:out value="${conversacion.conversationId}" /></a></td>
     <td><c:out value="${conversacion.conversationStartFormat}" /></td>
     <td><c:out value="${conversacion.agentName}" /></td>
     <td><c:out value="${conversacion.colaName}" /></td>
     <td><select name="destino" class="select">
         <option value="">--</option>
         <option value="1">--PRUEBAS--Origin queue 1</option> 
         <option value="2">--PRUEBAS--Origin queue 2</option> 
     </select></td>

     <td><c:out value="${conversacion.customerName}" /></td>
     <td><c:out value="${conversacion.customerEmail}" /></td>
     <td><c:out value="${conversacion.asunto}" /></td>
     <td><c:out value="${conversacion.aparcamientoId}" /></td>
     <td><input class="boton" type="button" value="Desaparcar correo"/></td>
</tr>

</c:forEach>
</c:if>
</table>

My problem is trying to get the value of the select, I'm trying with:

var row_index = $(this).parent().index();
alert("row_index" + row_index);

var x = parseInt(row_index, 10);

indice = document.getElementsByName("destino")[x].selectedIndex;
if( indice == null || indice == 0 ) {
alert("NO HAY VALORES");
}else{
alert("HAY VALORES");
};

but when I press the button, I always get the value 9 in row_index, also I do not take the value of x to pass it to the index. Can someone help me with this, please?

    
asked by Davinia 25.01.2018 в 13:54
source

0 answers