Opening Web Page Dialog Boxes with Other Dialog Boxes - Child HTML
(Page 3 of 4 )
Setting and Reading Child HTML Element Values
In the JavaScript of the parent window, the following statement would access the value of an element in the child window.
myWindow.document.getElementById(ID).value
Assume that you have the following element in the child window:
<input type=”text” id=”I1”>
The following statement in the parent script would set the value of the Input Text control to “Peter”.
myWindow.document.getElementById('I1').value = "Peter";
And the following code in the parent script would read the value of the Input Text element from the child window into the variable, name, in the parent window:
var name = myWindow.document.getElementById('I1').value;
Setting and Reading Child HTML TD Content
The method is similar to the one explained above, but instead of the property, value, you have the property, innerHTML.
Assume that you have the following element in the child window:
<table>
<tr>
<td id="TD1">
The cell content
</td>
</tr>
</table>
The following statement in the parent script would set the content of the table cell element to “New Cell Content.”
myWindow.document.getElementById('TD1').innerHTML = "New Cell Content"
And the following code in the parent script would read the content of the table cell element from the child window into a variable (content) in the parent window:
var content = myWindow.document.getElementById ('TD1').innerHTML;
Next: Adding a Row in a Child Table >>
More HTML Articles
More By Chrysanthus Forcha