Forum Moderators: open
The process that comes to mind is:
1. In PHP addslashes to prepare special symbols.
2. Write a Javascript code, define a new var and post $message to it (VAR mymsg = '<?php echo $message;?>')
3. open a new window that points to a simple html form textarea.
4. Use Javascript to change the value of my textarea to the Javascript variable defined in my other window.
5. Use Window.Print to print it out.
6. Close the new window.
Is there an easier way? Can I do it without opening a new window?
Thanks in advance,
Dave
Won't that end up printing it out of the visitor's computer?
What exactly are you trying to do?
Do YOU want a copy of the message on paper?
What would you want that when it is you send the message in the first place?
Do you want the users computer to automatically print out the message?
To do that you will indeed need a new window otherwise you will get all the other pages content printing too.
You could use javascript to close the window after though.
-- Dave
Are you storing the information in a database already? If not, you could first write the message into a DB, then send it, then create a page that only you access that just brings up the messages one at a time for you to print.
I hadn't thought about using a db, but I could write $message to a sql table, use javascript to open a new PHP page which reads the db to get the msg and just prints it as straight html (or put it in a <textarea> block which may cut down on formatting issues). Then all I'd have to do is a window.print() once the page has finished loading...
Someting like <body onLoad="Window.Print()">
I ought to be able to do that. Great idea! Thanks!
How would I close the window and return focus to my original document (my email creator/sender)?
-- Dave