Updating Parent TextBox from Child Popup Window

Discussion in 'ASP .Net' started by Jason Wilson, Sep 15, 2006.

  1. Jason Wilson

    Jason Wilson Guest

    I am trying to create a popup window that will give a user the option
    to lookup a value and return it to a textbox on the parent page.

    Here is my relevant code:

    Code on Parent

    <form id="frmCoding" action="CodeView.aspx" method="post"
    runat="server">
    ...
    CPT1<asp:Textbox ID="txtCPT1" runat="server" Width="240px" />
    <input ID="butLookupCPT1" type="button"

    style="color:#003399;font-family:Arial;font-weight:bold;"
    onclick="javascript:LaunchCPTLookup();" value="?" />
    ...
    <script type="text/javascript">
    function LaunchCPTLookup(){
    window.open("CPTLookup.aspx", "CPTLookup");
    }
    </script>

    Code on Child

    <form id="frmTest" name="frmTest">
    <input type="text" name="txtTest" />
    <input type="button" onclick="Test();" value="Test" />
    </form>

    <script type="text/javascript">
    function Test(){
    if (window.opener && !window.opener.closed)
    window.opener.document.frmCoding.txtCPT1.Value =
    document.frmTest.txtTest.Value;
    window.close();
    }
    </script>

    I don't get any errors on the child, but when I enter a value and click
    the button the window closes but nothing changes on the parent.

    Help?
    Jason Wilson, Sep 15, 2006
    #1
    1. Advertising

  2. Jason Wilson

    Daniel Guest

    simple: change the property reference to value instead of Value on both


    window.opener.document.frmCoding.txtCPT1.value =
    document.frmTest.txtTest.value;

    Have a great day!

    - Danny

    Jason Wilson wrote:
    > I am trying to create a popup window that will give a user the option
    > to lookup a value and return it to a textbox on the parent page.
    >
    > Here is my relevant code:
    >
    > Code on Parent
    >
    > <form id="frmCoding" action="CodeView.aspx" method="post"
    > runat="server">
    > ...
    > CPT1<asp:Textbox ID="txtCPT1" runat="server" Width="240px" />
    > <input ID="butLookupCPT1" type="button"
    >
    > style="color:#003399;font-family:Arial;font-weight:bold;"
    > onclick="javascript:LaunchCPTLookup();" value="?" />
    > ...
    > <script type="text/javascript">
    > function LaunchCPTLookup(){
    > window.open("CPTLookup.aspx", "CPTLookup");
    > }
    > </script>
    >
    > Code on Child
    >
    > <form id="frmTest" name="frmTest">
    > <input type="text" name="txtTest" />
    > <input type="button" onclick="Test();" value="Test" />
    > </form>
    >
    > <script type="text/javascript">
    > function Test(){
    > if (window.opener && !window.opener.closed)
    > window.opener.document.frmCoding.txtCPT1.Value =
    > document.frmTest.txtTest.Value;
    > window.close();
    > }
    > </script>
    >
    > I don't get any errors on the child, but when I enter a value and click
    > the button the window closes but nothing changes on the parent.
    >
    > Help?
    Daniel, Sep 15, 2006
    #2
    1. Advertising

  3. Jason Wilson

    Jason Wilson Guest

    Gotta luv case sensitivity


    Daniel wrote:
    > simple: change the property reference to value instead of Value on both
    >
    >
    > window.opener.document.frmCoding.txtCPT1.value =
    > document.frmTest.txtTest.value;
    >
    > Have a great day!
    >
    > - Danny
    >
    > Jason Wilson wrote:
    > > I am trying to create a popup window that will give a user the option
    > > to lookup a value and return it to a textbox on the parent page.
    > >
    > > Here is my relevant code:
    > >
    > > Code on Parent
    > >
    > > <form id="frmCoding" action="CodeView.aspx" method="post"
    > > runat="server">
    > > ...
    > > CPT1<asp:Textbox ID="txtCPT1" runat="server" Width="240px" />
    > > <input ID="butLookupCPT1" type="button"
    > >
    > > style="color:#003399;font-family:Arial;font-weight:bold;"
    > > onclick="javascript:LaunchCPTLookup();" value="?" />
    > > ...
    > > <script type="text/javascript">
    > > function LaunchCPTLookup(){
    > > window.open("CPTLookup.aspx", "CPTLookup");
    > > }
    > > </script>
    > >
    > > Code on Child
    > >
    > > <form id="frmTest" name="frmTest">
    > > <input type="text" name="txtTest" />
    > > <input type="button" onclick="Test();" value="Test" />
    > > </form>
    > >
    > > <script type="text/javascript">
    > > function Test(){
    > > if (window.opener && !window.opener.closed)
    > > window.opener.document.frmCoding.txtCPT1.Value =
    > > document.frmTest.txtTest.Value;
    > > window.close();
    > > }
    > > </script>
    > >
    > > I don't get any errors on the child, but when I enter a value and click
    > > the button the window closes but nothing changes on the parent.
    > >
    > > Help?
    Jason Wilson, Sep 15, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Earl Teigrob
    Replies:
    1
    Views:
    5,815
    Earl Teigrob
    Jun 16, 2004
  2. Noel Dolan
    Replies:
    0
    Views:
    215
    Noel Dolan
    Jul 18, 2004
  3. Spammay Blockay
    Replies:
    1
    Views:
    401
    Dietmar Meier
    Feb 4, 2005
  4. Replies:
    5
    Views:
    144
  5. Bitswapper
    Replies:
    5
    Views:
    118
    Prasad, Ramit
    Aug 27, 2013
Loading...

Share This Page