469,607 Members | 1,953 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,607 developers. It's quick & easy.

Updating Parent TextBox from Child Popup Window

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?

Sep 15 '06 #1
2 7488
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?
Sep 15 '06 #2
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?
Sep 15 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by mkobus | last post: by
2 posts views Thread by chuckdfoster | last post: by
10 posts views Thread by sqlboy2000 | last post: by
5 posts views Thread by midnight_use_only | last post: by
2 posts views Thread by epaetz | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.