In this fourth part of a five-part series that details some of the things you can do with web page dialog boxes, you will learn how to change and add content to the immediate parent box, add a row to a parent dialog box, and much more.
More Tricks with Web Page Dialog Boxes - Parent Table (Page 2 of 5 )
Setting and Reading Parent HTML TD Content
The method is similar to the above, but instead of the value property, you use the innerHTML property.
Assume that you have the following element in the parent window:
<table>
<tr>
<td id="TD1">
The cell content
</td>
</tr>
</table>
The following statement in the child script would set the content of the table cell element to “New Cell Content.”
myParent.document.getElementById('TD1').innerHTML = "New Cell Content"
The following code in the child script would read the content of the table cell element from the parent window into a variable in the child window:
var content = myParent.document.getElementById ('TD1').innerHTML;
Adding a Row in a Parent Table
Here, we shall see how you can add a row to a table in the parent dialog box. The process is the opposite of adding a row to a table in the child window.
The following statement will insert a row in a table in the parent window:
When you insert a row, the row is empty; you need to insert cells. When you insert a cell, it is empty; you need to insert its content. Once you have the reference, the process is the same as the one we learned in the previous part of the series.