dcsimg
www.webdeveloper.com
Results 1 to 5 of 5

Thread: Calling PHP with Javascript

  1. #1
    Join Date
    May 2005
    Posts
    11

    Calling PHP with Javascript

    I have a problem trying to call a PHP script from Javascript. My webpage has the extension .php. What I need to do is call the function email when my Javascript var doneAction is complete. Where am I wrong in this code? Please Help!

    <?
    function email()
    {
    window.open("mailto:YourEmail@provider.com?&subject=WellDone");
    }
    ?>
    <SCRIPT language=JAVASCRIPT type=TEXT/JAVASCRIPT>
    var sourceDir = "";
    var doneAction = "function email";
    </SCRIPT>

  2. #2
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    lots.

    1. php is done on the server, thus javascript and PHP can not interact
    2. window.open is javascript, not PHP.
    3. you script tag is depreciated.
    4. functions do not have the keyword function in front of them when executed.


    I could go on with a few more, but I think you get the point.
    now what exactly do you want to do?

  3. #3
    Join Date
    May 2005
    Posts
    11
    What I am trying to do is have the email client on a computer open up after the variable doneAction is complete. This code is inside a wordsearch puzzle. Originally, when var doneAction was complete a simple alert popped up saying well done. What I would like to do is have it so that the person completing the wordsearch can email me their name so I can tell who has done the wordsearch. The reason for opening the email client only when the puzzle is complete is to be assured that the person actually completed the puzzle. The window.open Javascript will work but it opens the email client as soon as you enter the page. Here is the original doneAction code.
    var doneAction = "alert(\"Well done!\");";
    Is it possible to activate the email client any other way?
    Is it possible to have it that when you click the alert button to then activate the email client?

  4. #4
    Join Date
    Jun 2003
    Location
    here
    Posts
    4,551
    I don't think so.

    you could just do:
    var doneAction = "window.open('sendName.php');";

    and then write a simple mail script in PHP. Just checking, but are you sure you even have PHP? I've had people before who's host doesn't suport it asking for code, which they then claim doesn't work.

  5. #5
    Join Date
    May 2005
    Posts
    11
    I have tried this to open another webpage after var doneAction
    var doneAction = "window.open('sendentry.htm');";
    Then I have a PHP mail script but the doneAction will not work! What is wrong with this?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles