#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0

    Combining dhtml with PHP


    Hi,
    id like to know if its possible to combine the server side features of php with the client side features of dhtml?
    i want to script a php page width a dynamic menu... it should contain a "mouse over" effect... i saw these on several dhtml pages...

    if its possible to do, could you plz be so kind and write a shot example... since i am a total newbie to php and dhtml

    thx in advance - GaNyMeD
  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0
    hello? *knock*knock* anyone there?

    reply plz
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    The DHTML and php are independent. Just use javascript/HTML where you want.
  6. #4
  7. No Profile Picture
    Gdelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    PHP can output any kind of text you want to the browser, including HTML, DHTML, and Javascript, (or even just plain ASCII text if you want). There is no way for PHP to "know" what is going on on the client-side, with DHTML or Javascript; it can only get information from browser requests, such as posting a form, refreshing a page, or going to a new URL. (It can also read cookies).

    So really the point is, you can use PHP to send any DHTML script you want to the browser, and you can use the server-side aspects of PHP to help you output that script (links from a database, etc...), but once the script has loaded, PHP's job ends, and the browser takes over. PHP doesn't know anything else, until the browser requests another page, or clicks "Submit" on a form.

    So just browse all the example DHTML scripts, you can find online, and understand that PHP can output *any* of those, filling in some areas with variables, etc... and then send them to the browser, just like HTML.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com
  8. #5
  9. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0
    thx for that answer
    ...
    i tried to combine parts of serveral scripts...

    Code:
    <html>
    <head>
    <script>
    var myimages=new Array()
    var preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image()
    myimages[i].src=preloadimages.arguments[i]
    }
    }
    
    window.onload=function(){
    setTimeout('preloadimages(/"big2.jpg/")',400);
    document.location.href="big.html";
    }
    </script>
    <title>test</title>
    </head>
    <body bgcolor=#ffffff>
    nx
    </body>
    </html>
    but i doesnt work as i want...
    it should preload the image and then go to the next page showing the image...
    but instead it immediatly goes to the next page without preloading the image...

    what did i wrong?
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jan 2001
    Location
    UK
    Posts
    527
    Rep Power
    14
    Try this.
    I assume the var instead of function was a typo.
    I think the problem is that while the timeout is waiting 400/1000 sec the document.location executes so the timeout never gets to execute. If you put the document.location at the end of the function this will be avoided.

    <html>
    <head>
    <script>
    var myimages=new Array()
    function preloadimages(){
    for (i=0;i<preloadimages.arguments.length;i++){
    myimages[i]=new Image();
    myimages[i].src=preloadimages.arguments[i];
    document.location.href="big.html";
    }
    }

    window.onload=function(){
    setTimeout('preloadimages(/"big2.jpg/")',400);

    }
    </script>
    <title>test</title>
    </head>
    <body bgcolor=#ffffff>
    nx
    </body>
    </html>

    John
  12. #7
  13. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0
    hmm thx for your answer john... but your script doenst work for me too

    same effect: it redirects immediatly to the next page and then slowly loads the image...
  14. #8
  15. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0
    hmm ive also another question.. would it be possible to make the script not timeout depend anymore? i think it would be better to have a script that only switches the page when the preloading is finished... since a dsl user will load the images faster than a 28.8k modem user...
  16. #9
  17. No Profile Picture
    Gdelian monster
    Devshed Regular (2000 - 2499 posts)

    Join Date
    Jul 1999
    Location
    Central Florida, USA
    Posts
    2,307
    Rep Power
    61
    This is really a question that should be asked in the Javascript forum; it has nothing to do with PHP.
    The real n-tier system:

    FreeBSD -> PostgreSQL -> [any_language] -> Apache -> Mozilla/XUL

    Amazon wishlist -- rycamor (at) gmail.com
  18. #10
  19. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2001
    Posts
    8
    Rep Power
    0
    k im sorry.... never the less, thx for your help

    ive startet a topic the javascript/html forum

IMN logo majestic logo threadwatch logo seochat tools logo