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 3 of 3
  1. #1
    New Coder
    Join Date
    Mar 2008
    Posts
    92
    Thanks
    19
    Thanked 0 Times in 0 Posts

    Calling javascript function in php

    Hi,

    I have a page where you can upload files from your computer or from a url.

    In file_upload.php I have 2 forms and a javascript function.

    One submits to upload_from_computer.php using an iframe for an ajax-like upload:

    Code:
    <form name="upload_from_computer" action="edit/upload_from_computer.php?page_id=<? echo $page_id; ?>" method="post" enctype="multipart/form-data" target="upload_target">...and so on

    The other submits to upload_from_url.php

    Code:
    <form name="upload_from_url" ENCTYPE="multipart/form-data" action="edit/upload_from_url.php?page_id=<? echo $page_id; ?>" method="post">...and so on
    The javascript function is:
    Code:
    <script type="text/javascript">		
    		function done_uploading() {
    			alert("done");
    		}	
    </script>
    When the upload_from_computer.php is done I use:

    Code:
    <script language="javascript" type="text/javascript">window.top.window.done_uploading();</script>
    But if I put this in upload_from_url.php I get an error in firefox:

    Error: window.top.window.stopUpload is not a function
    /edit/upload_from_url.php?page_id=2
    Line: 1

    I think it works for upload_from_computer because of the iframe, and window.top.window selects the correct page.

    Anyone know how to call stopUpload() from upload_from_url.php?


    Thanks

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    We'd have to see much more of the code and how it's all working together to have any idea what could be going on.

  • #3
    New Coder
    Join Date
    Mar 2008
    Posts
    92
    Thanks
    19
    Thanked 0 Times in 0 Posts
    Thanks...Actually, I figured something out. This is really a job for an ajax call. The script I was using to upload from the computer can simply call a javascript function in another file using window.top.window (I guess because of the iframe). But, uploading from a website I just need an ajax call to send a string to a php file (the url).


    Thanks


  •  

    Posting Permissions

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