fj1200 Posted October 20, 2008 Share Posted October 20, 2008 Sorry - probably another thick js question - but I'm stummped. Not been on js for long and I'm not a programmer. I have a simple php form entering 5 fields into a MySQL db. I now need to print off a form populated by those elements. Printing is done by js and the page that does the db inserting has a redirect in it. Works ok - so far so good..... link <rel=\"alternate\" media=\"print\" HREF=\"http://servername/note.php\"> with... <script language="Javascript1.2"> <!-- function printpage(){ window.print(); } //--> </script> <script language="javascript"> However on printing the page note.php has no data on it. I have also tried using a sql query in an includefile for the page to be printed - I do this elsewhere - but need to pass one of the original elements to it for the query to work. I could do the MAX(id) no. query on the db but eventually it will be multi-user and MAX(id) may be a different record if 2 get entered at the same time. Can I use $_POST data? If so how - I can't get that to work either. Is the js causing a problem in transfering the form elements through to the final printed form? Quote Link to comment https://forums.phpfreaks.com/topic/129229-passing-php-post-elements-through-javascript-to-a-3rd-page/ Share on other sites More sharing options...
web_loone_08 Posted October 21, 2008 Share Posted October 21, 2008 try this: <link rel=\"stylesheet\" type=\"text/css\" href=\"http://servername/note.php\" media=\"print\"/> <script type="text/javascript"> window.onload = function() { window.print(); } </script> Quote Link to comment https://forums.phpfreaks.com/topic/129229-passing-php-post-elements-through-javascript-to-a-3rd-page/#findComment-670607 Share on other sites More sharing options...
cuboidgraphix Posted October 21, 2008 Share Posted October 21, 2008 Hi fj1200, I think i understand what you're asking. I had a similar problem trying to pass variables from one page to the next. Well there are two ways to do this. either pass them in a using a form with hidden elements or pass them through a $_session ... but that would require you to have a session in your page. I tried doing it via javascript but it's too complicated for me. What I did was simply create a session.. and through the same session I passed any variable I wanted from one page to the next. I hope I have helped in some way. Quote Link to comment https://forums.phpfreaks.com/topic/129229-passing-php-post-elements-through-javascript-to-a-3rd-page/#findComment-671216 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.