#1
  1. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22

    Exclamation


    Here is zie problem!

    I have a page which is http://www.mba4consultancy.co.uk/mood.html

    it is a questionaire, i have a print and see results button on the mood.html
    page, both buttons also submit the data to moodresults.php3 so that they can recieve help. (the page is all about moving home).

    this is the print code in moodresults.php3...

    //Print command

    if ($button == "Print Results") {
    echo ("<script language=javascript>");
    echo ("window.print()");
    echo ("</script>");
    }

    //end print command

    this code is to validate which button was pressed, wever it was the see results button or the print results button,

    as you can see from the code if the print results button is pressed then i use the javascript print function.
    and also easy to see is that if the see results button is pressed then the print function is ignored.

    So whats your problem i hear you all say.

    Well like i said, depending on what your responces where to the questions in mood.html the moodresults.php3 script puts out a different responce.

    The data is displayed correctly but when the print function kicks in and prints the page. The advice which id dynamically written by PHP is not printed. Its like all the javascript printfunction is doing is printing the UNPROSSED PHP, BUT the whole page is written in PHP with echo commands for the HTML. So it is printing the PHP just NOT the dynamic advice. take a look at it all.

    bellow is the moodresults.php3 script...



    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <HTML>

    <HEAD>

    <TITLE> Mood </TITLE>

    </HEAD>
    <body bgcolor="#ffffff" text="#000000" id=all>

    <?php

    //this section decides what advice should be given depending on what answetr they provided for the question

    $as=0;

    $bs=0;

    $cs=0;



    if($onea)

    {

    $as++;

    }

    if ($oneb)

    {

    $bs++;

    }

    if ($onec)

    {

    $cs++;

    }

    if ($twoa)

    {

    $as++;

    }

    if ($twob)

    {

    $bs++;

    }

    if ($twoc)

    {

    $cs++;

    }

    if ($threea)

    {

    $as++;

    }

    if ($threeb)

    {

    $bs++;

    }

    if ($threec)

    {

    $cs++;

    }

    if ($foura)

    {

    $as++;

    }

    if ($fourb)

    {

    $bs++;

    }

    if ($fourc)

    {

    $cs++;

    }

    if ($fivea)

    {

    $as++;

    }

    if ($fiveb)

    {

    $bs++;

    }

    if ($fivec)

    {

    $cs++;

    }





    //table header

    echo("<table width=100% border=1 cellspacing=3 cellpadding=3 bordercolor=84CEB5>

    <tr>

    <td bgcolor=bdded6>

    <p><font face=Verdana, Arial, Helvetica, sans-serif><b><font size=4>Test

    Results </font></b><br>

    <font size=2>So how did you do?</font><b> </b></font></p>

    </td>

    </tr><tr>

    <td>

    <p><font face=Verdana, Arial, Helvetica, sans-serif size=2>The system has examined

    your answers and has concluded the following:</font></p>

    </td>

    </tr>



    ");





    if (($as>=2)and($as<6))

    {

    echo("<tr>
    //advice responce 1

    <td bgcolor=bdded6><font face=Verdana, Arial, Helvetica, sans-serif size=2><B>Our test tells us that you seem quite contented with your current accommodation. You may not need to move, but you may want to because you want a change - theres more about this later</B></font></td>

    </tr>");

    }



    if ($bs>=2 && $bs<6)

    {

    echo("<tr>

    //advice responce 2
    <td bgcolor=bdded6><font face=Verdana, Arial, Helvetica, sans-serif size=2><B>We can tell from the test that you seem to be very dissatisfied with your current accommodation. It doesn't meet your needs, not does it appear that it is likely to. It may be time to move<br></B></font></td>

    </tr>");

    }



    if ($cs>=2 && $cs<6)

    {

    echo("<tr>

    //advice responce 3
    <td bgcolor=bdded6><font face=Verdana, Arial, Helvetica, sans-serif size=2><B>Is good enough, good enough. Do you need to think about adaptations to your home, or do you think it's time for a change.<BR></B></font></td>

    </tr>

    ");

    }



    echo("<div align=center><table width=100% border=0 cellspacing=0 cellpadding=0>");

    echo("<tr><td><p><font face=Verdana, Arial, Helvetica, sans-serif size=2><BR>But it is not just about practical matters. You may want to be closer to employment, amenities or family and friends. You may want a complete change of scene. Think about the following as a way of refining, re-enforcing, or challenging the options that are beginning to emerge. </font></p></td> </tr>");

    echo("<tr><td><p><font face=Verdana, Arial, Helvetica, sans-serif size=2><br>Just Because…</font></p><p><font face=Verdana, Arial, Helvetica, sans-serif size=2>Does the location of your current home</font></p> <table width=88% border=0 cellspacing=0 cellpadding=0 align=center> <tr><td width=8% align=center><b><font face=Verdana, Arial, Helvetica, sans-serif size=2 color=000052>a</font></b></td><td width=92%> <font face=Verdana, Arial, Helvetica, sans-serif size=2>provide you with everything you need socially, culturally, practically e.g. transport, services, employment etc</font></td></tr><tr><td width=8% align=center><b><font face=Verdana, Arial, Helvetica, sans-serif size=2 color=000052>b</font></b></td><td width=92%><font face=Verdana, Arial, Helvetica, sans-serif size=2>make is almost impossible to live your life in the way you want to</font></td></tr>");

    echo("<tr><td width=8% align=center><b><font face=Verdana, Arial, Helvetica, sans-serif size=2 color=000052>c</font></b></td> <td width=92%><font face=Verdana, Arial, Helvetica, sans-serif size=2>provide some of the things you need but not without difficulty</font></td></tr></table>");

    echo("<p><font face=Verdana, Arial, Helvetica, sans-serif size=2><b>This has been a fairly light hearted way to think about your housing needs and to some degree, aspirations. Clearly, it is important to give more rigorous consideration to the issues. The following section provides an opportunity to examine your current situation more thoughtfully and fully.</b></font></p> </td> </tr>");



    echo("<tr><td><p><font face=Verdana, Arial, Helvetica, sans-serif size=2><i><BR>Thinking About Moving?????</i></font></p><p><font face=Verdana, Arial, Helvetica, sans-serif size=2>Thinking about a change of accommodation? It is something most of us think about from time to time. Why do you want to move? Is it because of the area, or the particular accommodation? Have you ever done this before - on your own or with the support of others - and am are prepared for what lies ahead? Do you have the time, the information, the skill/expertise or will I need to think about asking others? Moving house is a major life change and takes into account a variety of issues including access to friends, soft intelligence about new neighbourhoods, realities about public transport, local amenities and other services and not just those included in optimistic directories. If you live with others, do their needs or aspirations differ from your own. Are there physical or other constraints that really do need to be realised?</font></p> </td> </tr> </table> <center><BR><BR><a href=right.html><font face=verdana size=1>home</a></center></div>");


    //Print command

    if ($button == "Print Results") {
    echo ("<script language=javascript>");
    echo ("window.print()");
    echo ("</script>");
    }

    //end print command
    ?>

    </BODY>

    </HTML>


    now goto http://www.mba4consultancy.co.uk/mood.html and answer the questions thewn click the print button, print the page and youll notice what i mean!

    please please help me this has taken so much time!
    "The cause will equal the effect after the effect has preceded the cause"
  2. #2
  3. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    please help me sum1, any1, pllleeeaaassseee
    "The cause will equal the effect after the effect has preceded the cause"
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    14
    I was able to print everything that was displayed on the the results page.

    : ----- >>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< ----- :
    : ---- You can't judge a man by his clothes ...or from his name ---- :
    : ------ But you can tell a lot about him ...from his signature !!! ------ :
    : ----- >>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< ----- :
  6. #4
  7. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    Take a look again,

    if you goto file print, then it does print the results, but if you click on the pritn results button it does not.

    If you look on the screen after saying yes to print, you will see that there is a table at the top with three rows (green , white green), and the advice is in bold. If u look at the print out version then the table only has 2 rows and the advice has NOT been printed out!
    "The cause will equal the effect after the effect has preceded the cause"
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    I was wondering if this is a browser dependent thing? I am only guessing but the script you have written starts printing the page before it has finished loading. (I think) Perhaps you should load the text into a new window and then print it- so that the window.print() is not in the window you are printing. ?????

    Don't quote me on this

    ie.
    <script>
    newWin=window.open("whatever.php3");
    newWin.print();
    </script>

    this way you are sure the window has loaded before the print.

    [Edited by JohnB on 03-06-2001 at 06:35 AM]
  10. #6
  11. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    I see where your cumming from and i have already thought of that, but i didnt want any pop up windows! i suppose i cud have a window that says "printing document", which then closes after the document has been printed.

    I would still like some help if any1 else has any ideas
    "The cause will equal the effect after the effect has preceded the cause"
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    Or just display the page with a "print this button" and call the print function from that. Might be a good idea to test to see if this the problem anyway
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2000
    Posts
    34
    Rep Power
    14
    My statement stands.

    I am a minimalist and only clicked 1a.

    However, when I click more another row shows up in the table.

    Under windows the whole thing prints.

    Can't you use print page() instead of window()?

    : ----- >>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< ----- :
    : ---- You can't judge a man by his clothes ...or from his name ---- :
    : ------ But you can tell a lot about him ...from his signature !!! ------ :
    : ----- >>>>>>>>>>>>>>>>>>>><<<<<<<<<<<<<<<<<<<< ----- :
  16. #9
  17. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22

    if you do page.print() then page is undefinied, and as i am not very advanced at java i dont know how to define the WHOLE page.

    I tried this.print()

    and the same problem occurs.

    I guess that i will have to tinker around wit a new window.

    Also if you put a print button on the page then it does print, but in the status bar you can see that the whole page has printed.
    "The cause will equal the effect after the effect has preceded the cause"
  18. #10
  19. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    The problem with printing automatically was that the page was not fully loaded. even though the advice is clearly there!

    Well i have finally given in and just put a button that appears if the user clicked print results!

    take a look if you like http://www.mba4consultancy.co.uk/mood.html


    if any one can think of a nice and tidy way to get the page to print then please post it on this thread.


    thanx for your help guys

    Chewie
    "The cause will equal the effect after the effect has preceded the cause"
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    I thought about this and the "proper" way to do it is to use the onLoad in the body tag.


    eg.
    <BODY onLoad="printpage();">


    where the printpage function:

    <script>
    function printpage(){
    window.print();
    }
    </script>

    John

    This should ensure that the page is fully loaded before calling the function. No need for the button! (I hope)

    [Edited by JohnB on 03-06-2001 at 09:40 AM]
  22. #12
  23. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    I havent tried this yet but i dont think it will work because, i tried something similar, i cant reme,ber what it was, but it was similar.

    Also if you look at the status bar in IE 5.0 then it shows that the page is NOT fully loaded until the user has clicked O.K or Cancel in the print Dialog box!

    So thats why i think that it wont work, but i will try it 2morrow!
    "The cause will equal the effect after the effect has preceded the cause"
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    If you put the window.print in a function it will not execute while the page is loading. The onLoad in the body should execute when the page has finished loading (just like pressing the print button) and the status bar will indicate this.

    Well this is what happens in theory anyway. Whatever happens I would advise you to check with all the popular browsers (strange things happen).
  26. #14
  27. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    i had a real quick try of this earlier and it wasnt happy about it, i was getting parse errors, but like i said i did it quickly so i'll have a go 2morrow, and see what happens. Keep an eye on this post
    "The cause will equal the effect after the effect has preceded the cause"
  28. #15
  29. Coding fun is drunk
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2001
    Location
    Lincoln, UK
    Posts
    127
    Rep Power
    22
    JohnB you are a GOD, it worked, i dont know what i did last time but it worked this time, just gotta clean up the code, thanx a mil'

    Chewie
    "The cause will equal the effect after the effect has preceded the cause"

IMN logo majestic logo threadwatch logo seochat tools logo