Jquery return value

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>'.

$('a#tableid').click(function() {
var vpetowner = $(this).attr('rowid');
return false;

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?

This is where a demo testing page that we can look at too, and apply our debugging techniques to, will be of great help for us to help you.

I am new to jquery, and there seems like it has some limits on passing values.

How about a simple javascript example that if I could see an explaination of how it would be done in jquery:

Say I have a page with a form that opens a modal popup window and list a table of values. This is real routine in the html/php/javascript world:

Code fragment from child window that has an onclick attached to the tr.

if ($powners_Row = $db->fetch($powners_Res))
		$kount = 0;
			$kount = $kount + 1;
			$rowid = "a".$kount;

			$vid = $powners_Row['ownerid'];
				'<tr id='.$rowid.' onMouseover=this.bgColor="lightgrey" onMouseout=this.bgColor="#FFFFFF" onclick="cell(this.id)">'.
					'<td>'.'<a href="javascript:void(0)" onclick="">'.$rowid.'</a>'.'</td>'.
		while ($powners_Row = $db->fetch($powners_Res));
	echo '</table>';



Now the function that handles this:

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;

This code works perfect.

OK, the questions.

  1. How to add a onclick to a <tr> in jquery? Note each row has unique id.
  2. 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.

For Dynamic client lookup on left click ajax scripts, then scroll down.