Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts

    Traversing this tree

    My biggest problem with DOM is getting to the elemnts on my page. Consider this structure;

    Code:
    <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.

    Code:
    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.
    Scott Stewart
    Always happy to learn from pros.

  • #2
    Regular Coder COBOLdinosaur's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    403
    Thanks
    2
    Thanked 31 Times in 31 Posts
    document.frames[0].document.getElementById('dataEdit')

    Is what you are looking for I think.
    100% standards compliant code is 100% correct 100% of the time.
    one of my toys from my repository and perhaps some help getting help

    Cd&

  • #3
    Regular Coder COBOLdinosaur's Avatar
    Join Date
    Jul 2002
    Location
    Canada
    Posts
    403
    Thanks
    2
    Thanked 31 Times in 31 Posts
    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
    100% standards compliant code is 100% correct 100% of the time.
    one of my toys from my repository and perhaps some help getting help

    Cd&

  • #4
    Regular Coder
    Join Date
    Nov 2002
    Posts
    567
    Thanks
    2
    Thanked 4 Times in 4 Posts
    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.
    Scott Stewart
    Always happy to learn from pros.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •