|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
updating a div from a database
I have read some threads on this topic, but am not sufficiently clear on the concept to implement what I want to do...
I have a static page with a hidden <div> that is made visible via a javascript link. The <div> is populated with info from a MySQL database. The div contains a form that is used to update the database. The way it currently works is that the form reloads the entire page, including the div. It seems to me that it would be more efficient to have the div updated with new data WITHOUT reloading the entire page. So, a double-level question: 1. Am I right that reloading the div alone is preferable to reloading the entire page? 2. If 'yes' to #1, how does one do that? innerHTML? Even if there is a fair amount of information? I'm not sure how to use innerHTML when generating an unknown amount of information being pulled from a database. Thanks.... |
|
#2
|
|||
|
|||
|
How are you going to reload only the div without reloading the entire page? I doubt that's possible.
|
|
#3
|
||||
|
||||
|
To do what you're wanting to do, you'd have to load all possible div values from the database and store them. Depending on how much info you're talking about, you may have some problems storing the info. Additionally, you may not be saving yourself anything as far as server resources (requesting a lot of data once isn't necessarily better than requesting much less data several times). There's also the possibility of people's turning js off. I'd consider doing a request for each change. That said, if you want to go with js, you'd just need to store your div content somewhere (hidden fields, say) and then use getElementById() and the innerHTML property to set the content of the div. You can probably do a search on either of these terms within this site to find the code to do it (I'm pretty sure I've typed it out recently).
__________________
Please don't PM me asking for solutions outside the scope of a thread. Keeping all responses in a thread stands to help others who come along later, which is after all what this forum's all about. |
|
#4
|
|||
|
|||
|
Thank you both. I'll probably stick with my current method of reloading the entire page.
|
|
#5
|
|||
|
|||
|
if you populate the <div> width a <? INCLUDE ""; ?> you can update the specific url of the inclusion.
|
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > updating a div from a database |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|