/    Sign up×
Community /Pin to ProfileBookmark

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:[email protected]?&subject=WellDone”);
}
?>
<SCRIPT language=JAVASCRIPT type=TEXT/JAVASCRIPT>
var sourceDir = “”;
var doneAction = “function email”;
</SCRIPT>

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@scragarMay 13.2005 — lots.

[list=1]
  • [*]php is done on the server, thus javascript and PHP can not interact

  • [*]window.open is javascript, not PHP.

  • [*]you script tag is depreciated.

  • [*]functions do not have the keyword function in front of them when executed.

  • [/list]


    I could go on with a few more, but I think you get the point.

    now what exactly do you want to do?
    Copy linkTweet thisAlerts:
    @crow1959authorMay 13.2005 — 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?
    Copy linkTweet thisAlerts:
    @scragarMay 13.2005 — 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.
    Copy linkTweet thisAlerts:
    @crow1959authorMay 13.2005 — 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?
    ×

    Success!

    Help @crow1959 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.2,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @AriseFacilitySolutions09,
    tipped: article
    amount: 1000 SATS,
    )...