Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Parent Window

Status
Not open for further replies.

Fubear

IS-IT--Management
Sep 11, 2002
299
GB
I have a web page with several HTML links to open new windows. I know I can use 'var x = window.open (...)' to be able to control the window that has been opened.

I have a select box for the user to select a record, and a link to open that records details in a new window. When the details are entered an the submit button clicked, then the information will be saved into the databse and the window will close.

What I want to do is have the details in the select box update when the window is closed, and only if closed by pressing submit and not the close button on the bar at the top.

The information in the select will either update, or have a new entry added depending on what action the user is making.

Is there a way to do this in Javascript? Or any other language for that matter (ASP.NET?)
 
Here is an example of scripting between windows. Two seperate window scripts are found below.

<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>

var newWindow;

function butOpenWin_onclick()
{
var winTop = (screen.height / 2) - 125;
var winLeft = (screen.width / 2) - 125;
var windowFeatures = &quot;width=250,height=250,&quot;;
windowFeatures = windowFeatures + &quot;left=&quot; + winLeft + &quot;,&quot;;
windowFeatures = windowFeatures + &quot;top=&quot; + winTop;

newWindow = window.open(&quot;newWindow.htm&quot;,&quot;myWindow&quot;,windowFeatures);
}

function butGetText_onclick()
{
if (typeof(newWindow) == &quot;undefined&quot; || newWindow.closed == true)
{
alert(&quot;No window is open&quot;);
}
else
{
document.form1.text1.value = newWindow.document.form1.text1.value;
}
}

function window_onunload()
{
if (typeof(newWindow) != &quot;undefined&quot;)
{
if (newWindow.closed == false)
{
newWindow.close();
}
}

}

</SCRIPT>
</HEAD>
<BODY onunload=&quot;window_onunload()&quot;>
<FORM NAME=form1>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Open newWindow&quot; NAME=butOpenWin
onclick=&quot;butOpenWin_onclick()&quot;>
<BR><BR>
NewWindow's Text
<BR>
<INPUT TYPE=&quot;text&quot; NAME=text1>
<BR>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Get Text&quot; NAME=butGetText
onclick=&quot;return butGetText_onclick()&quot;>
</FORM>
</BODY>
</HTML>


<HTML>
<HEAD>
<SCRIPT LANGUAGE=JavaScript>

function butGetText_onclick()
{
document.form1.text1.value = window.opener.document.form1.text1.value;
}

</SCRIPT>
</HEAD>
<BODY>
<FORM NAME=form1>
Opener window's text<BR>
<INPUT TYPE=&quot;text&quot; NAME=text1>
<BR>
<INPUT TYPE=&quot;button&quot; VALUE=&quot;Get Text&quot; NAME=butGetText LANGUAGE=JavaScript
onclick=&quot;butGetText_onclick()&quot;>
</FORM>
</BODY>
</HTML>

Maybe this will help you get started.

Brian
 
Does this help?

faq216-3388

Cheers,


[monkey] Edward [monkey]

&quot;Cut a hole in the door. Hang a flap. Criminy, why didn't I think of this earlier?!&quot; -- inventor of the cat door
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top