Link to home
Start Free TrialLog in
Avatar of mamuscia
mamusciaFlag for United States of America

asked on

javascript to highlight table row in opener window

I have a page that contains an HTML table.  Within a cell in each row, I have an edit image and when clicked, opens a new window with target='_blank'.   On that newly opened widow, if the user successfully updates and save the form data that is presented, I want to highlight the row on the calling window's table with background green.  If they did not successfully save the form I want to highlight the row on the calling window's table with background silver.

The same javascript file is used within the parent and newly opened window.

thanks.
ASKER CERTIFIED SOLUTION
Avatar of remorina
remorina
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mamuscia

ASKER

Your solution works standalone.  I'm trying to retrofit it to my code and have exactly as you have coded and it does not work.  The difference between my code and yours is that I already have an ID assigned to the table row and pass it to the external page, then pass it back to the JS file.

Do I need to hard code a literal in the getElementById?  I used firebug and the variables contain the correct values.  
INDEX.HTML
<tr id='row1'>
<td align='left' valign='top' bgcolor='#ffffff'>
<a href='javascript:void(0);' onclick='editscreen(this, "2010-03-07", "010BZ", "SLO2", "OS", "row1")' title='Edit this record'>   <img src='images/icon_edit.gif' border='0' alt='Edit Record'></a>
</td>

function editscreen(el, date_closed, ticket_num, slo, service_category, rowid) {
  var url = "indexqaedit.php";
  var parms = "?date_closed="+date_closed+
"&ticket_num="+ticket_num+
"&slo="+slo+"&service_category="+service_category+"&rowid="+rowid;
  var winparm = url+parms;
  editwin = window.open(winparm,'editwin','scrollbars=yes,menubar=no,resizable=yes,toolbar=no,location=no,status=no');
}

EXTERNAL.HTML
<input type='button' name='cancel' value='Cancel' class='buttonGO' onclick='highlightTableRow("row1", "td_silverbkgrnd");'/>

function highlightTableRow(rowid, classname) {
  opener.document.getElementById(rowid).className=classname;
  window.close();
}

Open in new window

Tried it again and it works like a charm.  thanks.
I misspelled getelementbyid.....!!!
Great, I was about to look into it again.
Glad it worked for you