Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

352
Vistas
Returning selected table/cell value back to parent window fails when using variable

I'm trying to return the value of a clicked-row from a table in a popup window back to the parent window.

It works correctly if I manually specifiy a value in the script.

window.opener.document.getElementById('adminticket').value = 12345; // this works fine

If I extract the value from the table that was clicked on and output the value that shows the correct value.

console.log (selectedticket); // this works fine

However, if I put the variable to be returned it does nothing and no console errors.

Full code:

<script>
    jQuery(document).ready(function($) {
        $(".clickable-row").click(function() {
            
            var table = document.getElementsByTagName("table")[0];
            var tbody = table.getElementsByTagName("tbody")[0];
            tbody.onclick = function (e) {
                e = e || window.event;
                var selectedticket = 0;
                var target = e.srcElement || e.target;
                while (target && target.nodeName !== "TR") {
                    target = target.parentNode;
                }
                if (target) {
                    var cells = target.getElementsByTagName("td");
                    selectedticket = (cells[0].innerHTML);
                }
            };                                
            
            console.log (selectedticket); // this works fine
            window.opener.document.getElementById('adminticket').value = 12345; // this works fine
            window.opener.document.getElementById('adminticket').value = document.getElementById(selectedticket); // this doesnt work
            window.opener.document.getElementById('adminticket').value = selectedticket; // this doesnt work
            
            this.window.close();
        });
    });
</script>

What am I missing here? Any ideas?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda