View Full Version : Perhaps I'm clicking up the wrong coding path

06-02-2006, 09:53 PM
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.

function sendEmail(){
$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='.$Records.'>here</a> to view record.';
$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()

<input type='button' value='Submit' onclick=(value='Submitted') title='Submit for review' style='text-decoration: none' >

I have tried this:

<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)

06-02-2006, 09:58 PM
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)