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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jan 2006
    Posts
    251
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Perhaps I'm clicking up the wrong coding path

    I have a button whose value changes upon being clicked.
    Want to add a reference to a function.

    The function will reside on the same page and send a HTML email.
    Code:
    <?php
    function sendEmail(){
    session_start();
    //EMAIL BEGIN
    $to = 'someone@somewhere.net';
    $subject = 'Record Submitted';
    $message = ' HTML formated email response<BR>All information submitted will be kept, ahem, confidential.<BR>
    View the new record <a href=http://152.97.20.194/view.php?Records='.$Records.'>here</a> to view record.';
    //MIME
    $headers  = 'MIME-Version: 1.0' . "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
    mail($to, $subject, $message, $headers);
    header("Location: viewdb4.php");
    }
    ?>
    In the following code, I need to call the function sendEmail()
    Code:
    <input type='button' value='Submit' onclick=(value='Submitted') title='Submit for review' style='text-decoration: none' >
    I have tried this:
    Code:
    <input type='button' value='Submit' onclick=(value='Submitted' && emailSend()) title='Submit for review' style='text-decoration: none' >
    Received the following error:
    missing ) in parenthetical
    viewdb4.php (line 1)
    (value='Submitted'
    Last edited by h8ids; 06-02-2006 at 09:12 PM.

  • #2
    Senior Coder
    Join Date
    Jul 2005
    Location
    New York, NY
    Posts
    1,084
    Thanks
    4
    Thanked 19 Times in 19 Posts
    There's a separation here between server and client code. JavaScript knows nothing about PHP and PHP knows nothing about JavaScript.

    So what you want is to setup something on your client that will spawn a server process to do X.

    How do you do that? You have to send a request to the server from the client. Two ways of doing that: 1) navigating to a url (either in a frame or in the current window or a popup even) 2) Using XMLHTTPRequest (the famous AJAX techniques)


  •  

    Posting Permissions

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