Current location: Hot Scripts Forums » Programming Languages » PHP » Running javascript before sending php mail


Running javascript before sending php mail

Reply
  #1 (permalink)  
Old 04-03-07, 08:46 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Question Running javascript before sending php mail

Hi
I have a situration were I need to send html throught mail() but it has Javascript in it and needs to run before its gets sent because email programs dont allow Javascript to be ran.

Simple Example:

PHP Code:



$body 
'<html>
<head>
<script type="javascript">

    function my_function()
    {
    // do stuff
    }

</script>

</head>
<body onLoad=my_function()>

</body>
</html>' 
;

$headers =  "From: $email\r\n" ;
$headers .= "MIME-Version: 1.0\r\n" ;
$headers .= "Content-type:text/html; charset:\iso-8859-1\r\n" ;
mail ($to$subject$body$headers); 
Thanks
Lex
__________________
01010000 01001000 01010000
Reply With Quote
  #2 (permalink)  
Old 04-04-07, 02:05 AM
nova912's Avatar
nova912 nova912 is offline
Code Guru
 
Join Date: Sep 2004
Location: Traverse City, MI, USA
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
What does you JS function do, can it be repeated in php, if yes do it in php.
__________________
"BTW, I can't program at all the only thing I figured out is how to upload templates to my server."
Reply With Quote
  #3 (permalink)  
Old 04-04-07, 12:04 PM
_net's Avatar
_net _net is offline
Newbie Coder
 
Join Date: Apr 2007
Location: Local Disk C:
Posts: 36
Thanks: 0
Thanked 0 Times in 0 Posts
I doubt java script functions would work well with php. I've tried similar things but won't work. I think its best to have them in a seperate file and include them into the .php file.
Reply With Quote
  #4 (permalink)  
Old 04-04-07, 03:47 PM
phpdoctor's Avatar
phpdoctor phpdoctor is offline
Code Guru
 
Join Date: Feb 2007
Location: New Zealand
Posts: 767
Thanks: 4
Thanked 2 Times in 2 Posts
Quote:
What does you JS function do, can it be repeated in php, if yes do it in php.
It does calculations with numbers and changes text in a html table.
I can do it in PHP. I thought of different way, thats using Hidden fields.
This should do it

The script is for a form and when submited in sends to a certain email address.
The email looks the same as form so the Javascript do calculation before sending,
Also all fields are READONLY.

If you have any other ways to do this, please tell me

Thanks for comments
Lex
__________________
01010000 01001000 01010000
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to create image using php and pass its site to javascript method PHP 4 04-03-07 08:19 AM
Flash Mail Form with php gointern PHP 1 03-30-06 05:07 AM
how can i stop my PHP mail going to BULK ? sham85131 PHP 2 03-06-06 02:43 PM
PHP multi-dimensional array sorting issue aqw PHP 2 06-24-05 11:09 PM
PHP Sessions on Win 98 Running Apache jonpthomas PHP 1 10-12-04 04:38 PM


All times are GMT -5. The time now is 05:58 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.