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?