View Single Post
  #1 (permalink)  
Old 09-27-06, 06:19 AM
zoliky's Avatar
zoliky zoliky is offline
Aspiring Coder
 
Join Date: Jun 2006
Posts: 537
Thanks: 0
Thanked 0 Times in 0 Posts
Send file names to parent window hidden input fields

I have the following JS functions:

Code:
function GetDisplayName(path)
{
  var i;
  if (
  (i = path.lastIndexOf("\\")) != -1 
	  || 
  (i = path.lastIndexOf("/")) != -1
   ) {
   return i < path.length ? path.substring(i + 1) : "";
   }
   return path;
   }
Code:
function BeginAttach()
{  	 
	var path = document.filesform.userFile.value;
  	var displayName = GetDisplayName(path);
  	
	self.opener.document.foo.attach1.value = displayName;
  	self.opener.document.foo.submit();
  	self.close();
}
the parent page has 10 hidden input field, something like:

Code:
<input type="hidden" name="attach1" value="">
<input type="hidden" name="attach2" value="">
etc..
In child window I have 10 file input field :

Code:
<input type="file" name="userFile[]" size="20">
<input type="file" name="userFile[]" size="20">
etc..
I don't really know what I need to do to send the file name of each "file" field to parent page.

Code:
self.opener.document.foo.attach1.value = 'FileName1';
self.opener.document.foo.attach1.value = 'FileName2';
Any idea?
Reply With Quote