Jump to content

Controlling a window


MrAdam

Recommended Posts

Basically what I'm trying to do is create a window using the window.open method (name set as 'idFinder') which is my little tool for finding an ID as the name kinda suggests. Once they find their ID i have a button which is to 'add' the id (which is stored in a text field) to the main window and close the idFinder window...I've been scouting around for a fairly long time and I've got no where, could anyone giy us any help?Cheers, Adam

Link to comment
Share on other sites

This is in the base window

var idFinder = window.open('yourPage.php','idField','params here');...<input type="text" name="userId" id="userId" />

This is in yourPage.php

function addMe(value){	window.opener.document.getElementById('userId').value=value;}...Jhecht <button onclick="addMe('Jhecht')">Add This User</button>

Link to comment
Share on other sites

I have no interest in competing with Jhecht, but since I wrote the code, I figured I'd post it. They're about the same.Page 1:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  <html> 	 <head>		 <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">		 <meta name="generator" content="Adobe GoLive">		 <title>Untitled Page</title>	 </head> 	 <body bgcolor="#ffffff">		 		 <input type="text" id='targetText' size="24" />		 <button name="buttonName" type="button" onclick="openWin()">openwindow</button>		 		 <script>			function openWin(){				  window.open("http://www.sophox.com/source.html","_blank","toolbar=yes, location=yes, directories=no, status=no, menubar=yes, scrollbars=yes, resizable=no, copyhistory=yes, width=400, height=400");			}		 		 </script>	 </body> </html>

Page 2:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">  <html>	<head>	</head>	<body bgcolor="#ffffff">	   <input type="text" id='sourceText' size="24" />	   <button onclick="sendID()">Send ID</button> 	   <script>		  function sendID(){			 s = document.getElementById('sourceText');			 t = window.opener.document.getElementById('targetText');			 t.value = s.value;		  }	   </script> 	</body> </html>

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...