[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

javascript to highlight table row in opener window

Posted on 2010-03-29
4
Medium Priority
?
325 Views
Last Modified: 2013-11-19
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.
0
Comment
Question by:mamuscia
  • 2
  • 2
4 Comments
 
LVL 22

Accepted Solution

by:
remorina earned 2000 total points
ID: 29067662
hi mamuscia,
I think you should have listed this question in JavaScript zone not JavaScript Frameworks.

However I've written a simple example for you that does your request, you can modify it as you like.

Simply the function will assign an ID to the <tr> where the launch button or link was clicked, then the child window will pass the requested classname to that <tr> element in the parent window depending on your result.

Cheers
row-highlight.zip
0
 

Author Comment

by:mamuscia
ID: 29090153
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

0
 

Author Closing Comment

by:mamuscia
ID: 31708688
Tried it again and it works like a charm.  thanks.
I misspelled getelementbyid.....!!!
0
 
LVL 22

Expert Comment

by:remorina
ID: 29222070
Great, I was about to look into it again.
Glad it worked for you
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

591 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question