Page 1 of 1

Retaining form data

Posted: Thu Jun 05, 2003 6:30 pm
by Galahad
I hope this is the correct forum for this question, if not, I'm sorry. Let me start by saying that am not very experienced with javascript. However, let me explain what I'm trying to do and see if any of you have ideas about how to go about it.

I have a php page which allows the user to upload files through a standard form. There is an option to search for a person to send an email to (when the upload is complete). I currently have that a link to a javascript funtion that pops up a new window which allows the user to search a database for the person to send the email to. Once the person is found, the popup closes and I want the name that was chosen to be sent when the rest of the form is submitted.

Currently the way it works is that when the popup closes, it reloads the parent window passing it the id of the person in the url. The problem with that is any information that is in the forms when the page is reloaded is lost. Is there a way I can have the javascript get some kind of return value from the page it loads without refreshing the page? Javascript doesn't have to be a part of the solution, but it seems (in my relative ignorance of javascript) that it may be able to do it. php sessions, as I understand it, will not work because the user needs to be able to have multiple windows open at once and sessions could get confused between windows. I did a search of the forums here, and while it seems like this has been discussed before but couldn't find anything helpful. How would you go about this problem?

Posted: Fri Jun 06, 2003 12:14 pm
by volka
the opener element might be useful

Code: Select all

<html>
	<body>
		<a href="javascript:void()" onClick="javascript:window.open('anotherDoc.html', '', 'width=100,height=50;');" >open search window</a>
		<form id="myForm">
			<input type="text" name="field1" />
		</form>
	</body>
</html>

Code: Select all

<html><!-- anotherDoc.html -->
	<head>
		<script type="text/javascript">
			function fillOpenerForm()
			&#123;
				opener.document.getElementById("myForm").field1.value = "tada";
				return true;
			&#125;
		</script>
	</head>
	<body>
		<button onClick="javascript:fillOpenerForm();">fill form</button>
	</body>
</html>

Posted: Fri Jun 06, 2003 5:31 pm
by Galahad
That is pretty much exactly what I was looking for. Thanks for the suggestion, volka. I really appreciate it.