I have a form, and in that form I have a div that list a table of pet owners.
This table is loaded from a file called findowner.php.
After clicking on the row of a pet owner I want to use the variable I got $(this).attr(‘rowid’). This is the owners id. In the php file I get it like this:
Other td elements here for name, address, etc.
'<td>'.'<a id="tableid" href="#" rowid='.$rowid.' >'.$rowid.'</a>'.'</td>'.
I can’t seem to get the val(vpetowner) into the forms $(‘#petowner’).
If I load the findowner by itself (for testing), the alert(vpetowner); line works. But if clicked from the div where loaded from the other file (editpets.php), it doesn’t alert and the $(‘#petowner’).val(vpetowner); doesn’t update.
How would I properly pass this from the div to parent?
function cell(id)
{
var x=document.getElementById('myTable').rows[id].cells;
opener.document.peditform.ownerid.value = x[0].firstChild.nodeValue;
opener.document.peditform.petowner.value = x[1.firstChild.nodeValue;
opener.document.peditform.ostreet.value = x[2].firstChild.nodeValue;
self.close();
}
This code works perfect.
OK, the questions.
How to add a onclick to a <tr> in jquery? Note each row has unique id.
How to send the three values obtained back to parent?
I don’t use this technique now, I used to, I now return the ownerid from the table row, then do a lookup through ajax to get the rest of the data. Much like dhtmlgoodies.com’s dynamic client lookup example. I also use the SACK library.
I only put this popup window example here to understand converting from javascript to jquery, and how to go from either a child window to parent, or from a division to a field on the form. But really this is very basic stuff in regular javascript and ajax.