Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

340
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!