View Full Version : Passing Values

10-01-2003, 02:23 AM
Hi All,

I am incorporating a Javascript function into an aspx page.

I have a page with a <input type="file" name="Ph1"> control where the user selects a photo to upload. I am trying to pass the name of the selected file to a pop up form to preview the photo (so the user can be sure it is the right one before uploading it).

This is my function, but it does not seem to like it.

<script language="Javascript">function GetPhoto1()
window.open('PreviewPhotos.aspx?FileName=' + document.form1.Ph1.value, "Preview", "width=300,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");

it is called by:
<asp:hyperlink id="lnkPhoto1" runat="server" navigateurl="javascript:GetPhoto1()">

In the pop up window page load I have the following:

strFileName = Request.QueryString("FileName")
Me.imgPhoto.ImageUrl = strFileName

Can anyone help me with what I am doing wrong?(nb if I remove the "?FileName=' + document.form1.Ph1.value" it opens the pop up, no problem, but obviously no image is displayed, so it appears the problem is in the passing of the file name)

Thanks in advance.

10-01-2003, 06:14 AM
Hi All,

Thanks everyone for looking but I have solved it as follows:

<script language="Javascript">function GetPhoto1()
ChildWindow = window.open('PreviewPhotos.aspx?FileName=' + document.forms[0].Photo1.value,
"PreviewPhotos", "width=300,height=300,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no");
function CheckWindow() { ChildWindow.close(); }

where Photo1 is the ID of the <input type="file"> rather than the name, and referencing the form as forms[0] rather then form1.


10-02-2003, 05:49 AM
I keep posting to my own thread 'cause no one else will ;)

I have refined my function to check that the user has selected a file name, as follows:

function GetPhoto1()
if (document.forms[0].Photo1.value == "")
{alert("You must select the photo first!")}
{ChildWindow = window.open('PreviewPhotos.aspx?FileName=' + document.forms[0].Photo1.value, "PreviewPhotos", "width=400,height=330,top=200,left=200,toolbars=no,scrollbars=no,status=no,resizable=no"); } function CheckWindow() { ChildWindow.close(); }

Now, I would like to add a function call in the "else" section that checks if the ChildWindow is open, and if it is, closes it. I know you can just send the new details to replace the old, but I actually want to close it first to ensure that it is not minimised. Can anyone help with this?

Thanks in advance!!

10-03-2003, 02:58 PM
you can activate the popup by focusing on it...

ChildWindow = window.open(...);

10-08-2003, 06:01 AM
Thanks Glenn, that will do the trick.:thumbsup: