Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: Passing Values

  1. #1
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Passing Values

    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");
    }
    </script>

    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.

  • #2
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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(); }
    </script>


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


  • #3
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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!")}
    else
    {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!!

  • #4
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts
    you can activate the popup by focusing on it...

    ChildWindow = window.open(...);
    ChildWindow.focus();
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________

  • #5
    New to the CF scene
    Join Date
    Oct 2003
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks Glenn, that will do the trick.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •