PDA

View Full Version : Traversing this tree


ScottInTexas
10-16-2003, 08:14 PM
My biggest problem with DOM is getting to the elemnts on my page. Consider this structure;


<body>
<table id="header"><tr><th></th></tr></table><br>
<div id="btnBar">
<table id="btntbl">
<tr><form id="tblTree" >
<th align="left" width="30%"></th>
<th align="left" width="30%"></th>
<th width="40%></th>
</tr></form>
</table>
</div>
<Div id="DBStruct" >
<table id="tblList">
<form id="tblColForm" >
<input type=>
<input type=>
<input type=>
<input type=>
</form>
</table>
</div>
<iframe id="displayframe" name="displayframe">
getIt.asp gets loaded here via javascript and contains this form
<form name="dataEdit" id="dataEdit" >
<table id=""displayTable"" >
<input id="thisOne" type="text" Value="" />
</table>
</form>
</iframe>
</body>


I am trying to get to the fields on the form inside the iframe. I have tried this code but it wont execute the second alert.



function DoButton(which){
alert("Doing button");
alert(document.getElementById("dataEdit").name);
}


I have cut all the garbbage out so you can see thiis clearly. So how would you get the value or place the value of the field "thisOne"?

Thanks, I hope someone sees this in this forum. I just thought it was more appropriate to the DOM forum.

COBOLdinosaur
10-16-2003, 11:12 PM
document.frames[0].document.getElementById('dataEdit')

Is what you are looking for I think.

COBOLdinosaur
10-16-2003, 11:15 PM
or more correctly:

top.frames['displayframe'].document.getElementById('dataEdit')

Thought my preference would be:

top.frames['displayframe'].document.forms['dataEdit']

For better cross-browser support

ScottInTexas
10-17-2003, 01:15 PM
Thanks for your reply.

I hope I get a grip on the Parent/child node business here soon. Then maybe I wont have to ask bonehead questions. I keep looking at MS DOM documentation and after a couple of minutes I have to avert my eyes before they start bleeding.

I did find a nice tutorial that is a little more friendly on another web site (brainjar) so after reading that I may be able to work a little cleaner.

Thanks again.