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.
Page 1 of 2 12 LastLast
Results 1 to 15 of 20
  1. #1
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts

    HELP: PASSING data from one frame to another frame in a frameset

    guys help pls.. i need to pass the data in the textfields from the left frame to the textfields in the right frame of my frameset. (ex: dslnum of frame1 will be pass to txtDSLTN of frame2)

    frame1:
    http://www.mediafire.com/?hge1ws29mdhmu7e

    frame2:
    http://www.mediafire.com/?k83cb64wbpskw97


    thanks in advance!

  • #2
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    you must give the frames a name, that is used for refence:
    <frame name="FrameName" src="mydocument.htm">
    every frame name must be unique.

    Then, if you example have a <span id="TagId"></span>
    you can refer to that tag using javascript as:
    parent.FrameName.document.getElementById('TagId').innerHTML;

  • #3
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i dont know how that works.. can u elaborate further? im new in javascript.. consider me as a freshman..

  • #4
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what i have is this:
    <script type="text/javascript">
    function copyFields(form)
    {
    parent.mainFrame.form1.dslnum.value=document.frmNotesMaker.txtDSLTN.value;
    }
    </script>

  • #5
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    Quote Originally Posted by anaid54 View Post
    what i have is this:
    <script type="text/javascript">
    function copyFields(form)
    {
    parent.mainFrame.form1.dslnum.value=document.frmNotesMaker.txtDSLTN.value;
    }
    </script>
    You cannot change data in another document that way;

    AFAIR you can do it the other way around by using:
    document.form1.dslnum.value=parent.secondFrame.frmNotesMaker.txtDSLTN.value.
    in the recieving document
    This way applying data FROM another document an not TO

  • #6
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    I gave you this SAME ANSWER before.

    This code is WRONG:
    Code:
    function copyFields(form)
    {
    	var frmNotesMaker = window.parent.mainFrame.document.frmNotesMaker;
    	document.frmNotesMaker.txtDSLTN.value = document.form1.dslnum.value;
    }
    The part in red DOES NOT BELONG there. Get rid of it.

    I think it is confusing to use the same name in two different ways.

    And it is also POINTLESS to pass the form reference into the function and then IGNORE it.

    *I* would have coded something like this:
    Code:
    function copyFields(form)
    {
    	var otherForm = window.parent.mainFrame.document.frmNotesMaker;
    	otherForm.txtDSLTN.value = form.dslnum.value;
    }
    And the OTHER problem is that your <form> in the mainFrame DOES NOT HAVE A NAME!!!

    Code:
    <form id="frmNotesMaker" action="">
    It *NEEDS* a NAME:
    Code:
    <form name="frmNotesMaker" action="">
    And then it works.
    Last edited by Old Pedant; 08-31-2010 at 01:58 AM.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #7
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Quote Originally Posted by lerura View Post
    You cannot change data in another document that way;
    Yes, you can.

    I do it all the time.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #8
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    Quote Originally Posted by Old Pedant View Post
    I gave you this SAME ANSWER before.
    When???
    Quote Originally Posted by Old Pedant View Post
    This code is WRONG:
    Code:
    function copyFields(form)
    {
    	var frmNotesMaker = window.parent.mainFrame.document.frmNotesMaker;
    	document.frmNotesMaker.txtDSLTN.value = document.form1.dslnum.value;
    }
    The part in red DOES NOT BELONG there. Get rid of it.

    I think it is confusing to use the same name in two different ways.

    And it is also POINTLESS to pass the form reference into the function and then IGNORE it.

    *I* would have coded something like this:
    Code:
    function copyFields(form)
    {
    	var otherForm = window.parent.mainFrame.document.frmNotesMaker;
    	otherForm.txtDSLTN.value = form.dslnum.value;
    }
    Your example is suited for putting in the right frame document.
    Except from that it will apply the data from the "right" document to the "left" document.

    It should be:

    function copyFields(form)
    {
    var otherForm = window.parent.mainFrame.document.frmNotesMaker;
    form.dslnum.value = otherForm.txtDSLTN.value;
    }

  • #9
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Originally Posted by Old Pedant
    I gave you this SAME ANSWER before.
    When???
    Weeks ago. Two weeks I think. Not sure it was in this same forum.

    **************

    Your example is suited for putting in the right frame document.
    Except from that it will apply the data from the "right" document to the "left" document.
    No, you are wrong.

    Her <frameset> looks like this:
    Code:
    <html>
    <head>
    </head>
    <frameset cols="50%,50%">
    <frame name="leftside" src="frame1.html"></frame>
    <frame name="mainFrame" src="frame2.html"></frame>
    </frameset>
    </html>
    So my code--when placed in "frame1.html"--will take the contents of "form1.dslnum" from the left frame and place them into the field "frmNotesMaker.txtDSLTN" in the right side "mainFrame".

    In actuality, the answer I gave her back then copied several fields from the left frame to the right. I gave her complete working code (the frameset and both files for the frames) and somehow I guess in modifying it to match her actual field names she mucked it up.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #10
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Yeah, I still have the code sitting here on this machine. August 17th.

    Here are the files I gave her:

    MAIN.html:
    Code:
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    <frameset cols="*,*" frameborder="no" border="0" framespacing="0">
      <frame src="LEFT.html" name="leftFrame" id="leftFrame" title="leftFrame" />
      <frame src="RIGHT.html" name="mainFrame" id="mainFrame" title="mainFrame" />
    </frameset>
    <noframes><body>
    </body></noframes>
    </html>
    LEFT.html:
    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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    <script type="text/javascript">
    function copyFields(form)
    {
        var other = window.parent.mainFrame.document.form1;
        other.phonenumber.value = form.phonenumber.value;
        other.fullname.value = form.fname.value + " " + form.lname.value;
        other.country.value = form.loc.options[form.loc.selectedIndex].text;
        other.txtarea.value = form.ticketnum.value 
                            + "\n" + form.prevticketnum.value
                            + "\n" + form.txtarea.value;
    }
    </script>
    </head>
    
    <body>
    <form id="form1" name="form1" method="post" action="">
      <p>Phone Number: 
        <input type="text" name="phonenumber" />
      </p>
      <p>First Name: 
        <input type="text" name="fname" />
      </p>
      <p>Last Name: 
        <input type="text" name="lname" />
      </p>
      <p>Location: 
        <select name="loc" >
          <option>united stated</option>
          <option>united kingdom</option>
          <option>australia</option>
        </select>
      </p>
      <p>Ticket Number: 
        <input type="text" name="ticketnum" />
      </p>
      <p>Previous Ticket Number: 
        <input type="text" name="prevticketnum" />
      </p>
      <p>
        <textarea name="txtarea" cols="45" rows="5"></textarea>
      </p>
      <p>
        <input type="button" value="Create" onclick="copyFields(this.form);" />
      </p>
    </form>
    </body>
    </html>
    RIGHT.html:
    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">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Untitled Document</title>
    </head>
    
    <body>
    <form id="form1" name="form1" method="post" action="">
      <p>DSL Number: 
        <input type="text" name="phonenumber" id="phonenumber" />
      </p>
      <p>Full Name: 
        <input type="text" name="fullname" id="fullname" />
      </p>
      <p>Country: 
        <input type="text" name="country" id="country" />
      </p>
      <p>
        <textarea name="txtarea" id="txtarea" cols="45" rows="5"></textarea>
      </p>
      <p>
        <input type="submit" name="create" id="create" value="Submit" />
      </p>
    </form>
    </body>
    </html>
    Go ahead, try them yourself. I even combined the two name fields into one as she asked and even created the right side textarea with the compound contents from the left side, as she asked.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #11
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    Sorry! I have confused the frames.
    Well ,I havent seen all the documents, so....

    aniad54: please ignore my last change.
    Last edited by Lerura; 08-31-2010 at 02:37 AM.

  • #12
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,189
    Thanks
    75
    Thanked 4,341 Times in 4,307 Posts
    Ten to one this all came about because she didn't give a NAME= to the <form> in the second frame.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.

  • #13
    Regular Coder Lerura's Avatar
    Join Date
    Aug 2005
    Location
    Denmark
    Posts
    908
    Thanks
    0
    Thanked 120 Times in 119 Posts
    Quote Originally Posted by Old Pedant View Post
    Ten to one this all came about because she didn't give a NAME= to the <form> in the second frame.
    The worst when making webpages.
    That such "small" things, can make it all **** up;

  • #14
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    guys thanks!..

  • #15
    New Coder
    Join Date
    Aug 2010
    Posts
    24
    Thanks
    0
    Thanked 0 Times in 0 Posts
    what if i have this frameset: http://www.mediafire.com/?75dvswgvelw19a9

    this is somehow the like my other posts but im dealing with the radio buttons. what i want is when i click on the "create" button in form1 http://www.mediafire.com/?eld7a1rb21h799e it will pass the value to form 2 http://www.mediafire.com/?f0o060cdpyf06ya.

    so when i select "yes" in form1 and click on "create" it will autoselect "On" in form2. if i select "no" in form1 and click on "create" it will autoselect "off" in form2.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

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