Results 1 to 2 of 2

Thread: need help with this code

  1. #1
    Join Date
    Jan 2007
    Posts
    6
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default need help with this code

    hey guyz....am tryin to populate parent window from the child window usin a href link...its like in parent window there is a textbox with hyperlink which needs to be populated by child window.....in the child window i perform a search and from the search results when i hit the href link in search results...the text in the child window should populate the parent window textbox....and puttin my parent and child window....can someone plz add what needs to be added to it....i did it my self but...evertyhin is workin fine....but when i hit the href in child window....it is populatin the parent window but not with the text i got in search results...i can see "text Field" in the parent window text box...am not sure what to add to this but plz help me by addin what is necessary to it.....

    this is parent window (test.html)
    <head>
    <script>
    function loadParent() {
    pWindow = opener.window;
    pWindow.document.getElementById("textField").value = "Text Field";
    pWindow.document.getElementById("contentArea").innerHTML = "Content from child window";
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Travel Search</title>

    <link href="myCSS.css" rel="stylesheet" type="text/css" />
    </head>

    <body>
    <a href="ex.html" target="_blank">New window</a>
    <form>
    <input type="text" id="textField">
    </form>
    <div id="contentArea"></div>
    </body>
    this is child window (ex.html)
    <head>
    <script>
    function loadParent() {
    pWindow = opener.window;
    pWindow.document.getElementById("textField").value = "text Field";
    pWindow.document.getElementById("contentArea").innerHTML = "Content from child window";
    window.close()
    }
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <title>Untitled Document</title>
    </head>

    <body>
    <table width="200" border="1">
    <tr>
    <td><a href="#" onclick="loadParent()">populate parent</a>#post.code#</td>
    </tr>
    </table>
    </body>
    so when i click the href the text which am seein in the parent window..i highlighted it with red color....so plz add what is necessary to the code guyz.....thanx....

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Looks complicated. How about:

    whatever.htm
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    
    </head>
    <body>
    <a href="a.htm" target="_blank">a</a>
    <br>
    <input type="text" id="test">
    <div id="carea"></div>
    </body>
    </html>
    a.htm
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <script type="text/javascript">
    function pop_parent(){
    opener.document.getElementById('test').value='bob';
    opener.document.getElementById('carea').innerHTML='Stuff From the Child';
    }
    </script>
    </head>
    <body>
    <a href="#" onclick="pop_parent();return false;">Pop Parent</a>
    </body>
    </html>
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

Bookmarks

Posting Permissions

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