Jump to content

PHP and the DOM


rbw_ok

Recommended Posts

Here is what I've got. Using MySQL and PHP (and of course HTML and CSS) I have designed a nice website of the pets for adoption at our local SPCA. You search for a cat or dog using a couple of allowable criteria, then it pulls up a record with a picture, info, etc of the pet. I also added a 'next' and 'previous' button on each record so one could go thru and look at all the pets. It all looks and works good, except that when 'next' and 'previous' are clicked, the .php recalls itself, adds or increments the session variables, and then ~~flash/flicker~~ the new record is displayed. I'm wanting to know how to do this without having to recall the current .php code and always get that ~~flash/flicker~~ as the screen redraws itself. Checking around a bit, JavaScript talks about doing these types of things by manipulating the DOM (Document Object Module). The question is if I study and learn how to do this in JavaScript, I don't think I can necessarily access the variables, etc code I have which is PHP. PHP says it supports the DOM but doesn't seem to explain how to do this (that I can find). Hope I have explained this OK. Can anyone offer an idea of how to approach this?

 

Thanks.

Link to comment
Share on other sites

Similar to the use of javascript/DOM, but a little bit more intensive would be an AJAX function to do the content retreival.

On another note, why is the flashing and flickering happening? Does the page Flash and flicker when it gets losded the first time? Does it happen in all Browsers?

Edited by jlhaslip
Link to comment
Share on other sites

maybe I am not describing this flash/flicker right ... it is essentially because when any .html or .php calls another (or even itself) again, there is like a clear screen that happens first, before the next .html or .php is displayed. Sometime it is fast and you barely notice it, but most times you can see it actually clears everthing before displaying the next screen. This site ... http://www.dynamicdrive.com/dynamicindex17/virtualpagination.htm has several examples of how smooth it can look with javascript, but like I said, how do I learn to do this with php. Note how when you click on the next and previous buttons the entire page doesnt need to be refreshed.

Link to comment
Share on other sites

You search for a cat or dog using a couple of allowable criteria, then it pulls up a record with a picture, info, etc of the pet.

 

Perhaps it's the downloading of the next image; can you preload them?

 

Just as a test, delete the image so that you only have text and see whether you still get the flicker.

Edited by Wickham
Link to comment
Share on other sites

yes i have tried removing the image, and on differnet browswers, different cpu's, etc. yes the faster the cpu it is less noticeable, but as long as the entire screen is being refreshed, you will see a flicker. in my previous message i mentioned the link ... http://www.dynamicdrive.com/dynamicindex17/virtualpagination.htm ... if u go there and try each of the 4 demos there, u will se there is not a drop of flicker, because the entire url is NOT recalled each time ... somehow this manipulating the DOM stuff just magically chages anything anywhere on the page. thats what im trying to learn how to do using php. the help file of php says it can do these things, but no tutorial or easy explaantion that i can find anywhere.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...