Transferring text between frames

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • flowerful
    New Member
    • Mar 2010
    • 8

    Transferring text between frames

    How can I use java-script to access text entered by the user in a text box in one frame and transfer it into a text box in another frame.
    This is what i have so far:


    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
    <script language="JavaScript">
    
    
    </script>
    
    <title>nine</title> 
    </head>
    
    
    <frameset cols="50%,50%">
    <frame src="page1.html" scrolling="no" name="1">
    <frameset rows="50%,50%">
    <frame src="page2.html" scrolling="no" name="2">
    <frame src="page3.html" scrolling="yes" name="3">
    </frameset>
    
    </html>
    I know i have to use a function. But I am unsure whether it be document.write or var value.
    Last edited by gits; Mar 15 '10, 08:43 AM. Reason: please use code tags instead of bold tags when posting source code
  • RamananKalirajan
    Contributor
    • Mar 2008
    • 608

    #2
    I am not sure whether it will help you out or not. I created this code when i was working with iframe. Just make a try.

    Code:
    var iframeObj= parent.document.getElementById('Frame1');
    
    if ( iframeObj.contentDocument ) { // DOM
    		divObj = iframeObj.contentDocument.getElementsByTagName('div');
    	} else if ( iframeObj.contentWindow ) { // IE win
    		divObj = iframeObj.contentWindow.document.getElementsByTagName('div');
    	}
    	else //IE6
    	{
    		//IFrameObj.contentWindow.document;
    window.parent.Frame1.document.getElementById('iframeOverDiv').style.display='block';
    	}
    
    for(var i=0;i<divObj.length;i++)
    		{
    			if(divObj[i].id=="iframeOverDiv")
    			{
    					divObj[i].style.display='block';
    			}
    		}
    This code I used to access a Div object from one Iframe to another.

    Thanks and Regards
    Ramanan Kalirajan

    Comment

    • flowerful
      New Member
      • Mar 2010
      • 8

      #3
      Hi Ramanan Thanks for your prompt help. I have tried to simplify the script that you wrote me, to suit my task but I cannot work it out as I haven't, as yet learnt else and if. It does how ever give me a couple of pointers. Thankyou anyway. I shall keep trying different things.
      flowerful

      Comment

      • RamananKalirajan
        Contributor
        • Mar 2008
        • 608

        #4
        All the best. Keep trying. Post back if you are struck.

        Thanks and Regards
        Ramanan Kalirajan

        Comment

        • flowerful
          New Member
          • Mar 2010
          • 8

          #5
          //Done It! This is the blue page//


          <title>blue</title>
          </head>
          <body bgcolor="blue">
          <p>The blue Page</p>
          <h2>Hello</h2>
          <form>
          <input type=text value=""name="t extbox2"/>
          </form>
          </body>
          </html>

          //This is the yellow page//

          <title>yellow </title>
          <script type="text/javascript">

          </script>

          <body bgcolor="yellow ">
          <p>The yellow page</p>

          <h2>Please tell me your name</h2>

          <form>
          <input type=text value=""name="t extbox1"/>

          <a href=""onclick= 'parent.frame_c .document.forms[0].textbox2.value =
          parent.frame_a. document.forms[0].textbox1.value ;'>
          Click here to enter</a>

          </form>
          </head>
          </body>
          </html>
          //Green is just plain//

          //Index page changed a bit as well/


          <title>all</title>
          </head>


          <frameset cols="50%,50%">
          <frame src="yellow.htm l" scrolling="no" name="frame_a">
          <frameset rows="50%,50%">
          <frame src="green.html " scrolling="no" name="frame_b">
          <frame src="blue.html" scrolling="yes" name="frame_c">
          </frameset>

          </html>

          //As you can see, it wasn't too hard after all.;)

          Comment

          • RamananKalirajan
            Contributor
            • Mar 2008
            • 608

            #6
            You have used frameset.. so you were able to access the objects easily. But in Iframe i was screwed like anything to work. I am glad that you found out how to pass the value.

            Thanks and Regards
            Ramanan Kalirajan

            Comment

            Working...