By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,992 Members | 934 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,992 IT Pros & Developers. It's quick & easy.

Dynamically Refreshing a DIV or other control from the Server

P: n/a
I've been searching, but apparently not phrasing my search right, so I'm
going to float a question out here in the meantime...

I'm wondering how to go about refreshing the content of a control (say, a
selector) without refreshing the page. For example, if I have these selects:

Company: <pick a company>
Contact: <pick a contact>

When they pick the company, I'd like to refill the contact selector based on
who works for that company, but I don't want to refresh the form since the
record hasn't been saved yet.

I know I could use a hidden form or some embedded component to do an HTTP
pull, but we have a live support app that we use and it seems like it might
be keeping the connection to the server open until it's unloaded from the
browser, so I was curious if that's doable, and how big a resource hog it
is. We'll only have occasional instances where we'd need to do this sort of
thing, but in those cases it would probably be worth it. I've been poking
around in the live support code to find out how they do their refreshes, but
I'm kind of new to PHP and I haven't spotted the answer yet.

Thanks in advance...
Jul 17 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
I've been searching, but apparently not phrasing my search right, so I'm
going to float a question out here in the meantime...

I'm wondering how to go about refreshing the content of a control (say, a
selector) without refreshing the page.


Javascript.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #2

P: n/a
Clearly I have to use Javascript for the client piece...

The question is about how to do the server pull to get the fresh data. We
have some clients with very large databases - I don't want to pull down the
entire contacts table just so I can refresh the selector if the company
changes.
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:h7********************************@4ax.com...
On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
I've been searching, but apparently not phrasing my search right, so I'm
going to float a question out here in the meantime...

I'm wondering how to go about refreshing the content of a control (say, a
selector) without refreshing the page.


Javascript.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)

Jul 17 '05 #3

P: n/a
Philo Del Middleston wrote:
I've been searching, but apparently not phrasing my search right, so I'm
going to float a question out here in the meantime...

I'm wondering how to go about refreshing the content of a control (say, a
selector) without refreshing the page. For example, if I have these selects:

Company: <pick a company>
Contact: <pick a contact>

When they pick the company, I'd like to refill the contact selector based on
who works for that company, but I don't want to refresh the form since the
record hasn't been saved yet.

I know I could use a hidden form or some embedded component to do an HTTP
pull, but we have a live support app that we use and it seems like it might
be keeping the connection to the server open until it's unloaded from the
browser, so I was curious if that's doable, and how big a resource hog it
is. We'll only have occasional instances where we'd need to do this sort of
thing, but in those cases it would probably be worth it. I've been poking
around in the live support code to find out how they do their refreshes, but
I'm kind of new to PHP and I haven't spotted the answer yet.

Thanks in advance...


Sounds a little confusing to me. What it sounds like you want is to make
an onChange event for a SELECT element to display information based on
that option's value. This sounds like you will need to make at least one
HTTP/database request for each of the options - or for each time it's
changed. I'd suggest an iframe element, then in the onChange javascript
method, simply treat the IFRMAE as a named window (similar to in
framesets), and reload its content that way.

However, I think your comments about live support app and open server
connections are confusing me. If you want to make no more subsequent
requests until the data from the form is recorded, you'll have to find
all the possible choices and save the content for those somewhere
(likely with hidden elements) and make them visible when that option was
chosen. However, it would seem to be much more efficient to request the
data according to what the user chose since they aren't likely to go
through every option (or are they?).

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #4

P: n/a
The other guy that responded with "Javascript," while less than helpful, was
actually correct. I haven't gotten to try it yet, but here's a page that
appears to explain what I'm attempting to do:

http://www.webxpertz.net/faqs/jsfaq/jsserver.php

The whole application engine is XML based, and designed to run in a Windows
client app or over the web. In the client app I can use window.external
calls to pull whatever I need out of the database to rebuild an element, but
I wasn't sure how I was going to translate that to the web version. I wanted
to avoid using ActiveX controls or plugins since I don't want to be locked
in to IE (although I will require a Javascript enabled browser).

I would catch the onchange event for the first selector, make a quick fetch
for the new set of contact names and id's for the new company selected, then
rebuild the option list in the second selector.

The live support app is doing image.src manipulation to do server pulls,
although I never teased out exactly how they were getting the results. I'll
have to go back now and see if they're doing DOM tricks like this article
talks about.
Sounds a little confusing to me. What it sounds like you want is to make
an onChange event for a SELECT element to display information based on
that option's value. This sounds like you will need to make at least one
HTTP/database request for each of the options - or for each time it's
changed. I'd suggest an iframe element, then in the onChange javascript
method, simply treat the IFRMAE as a named window (similar to in
framesets), and reload its content that way.

However, I think your comments about live support app and open server
connections are confusing me. If you want to make no more subsequent
requests until the data from the form is recorded, you'll have to find
all the possible choices and save the content for those somewhere
(likely with hidden elements) and make them visible when that option was
chosen. However, it would seem to be much more efficient to request the
data according to what the user chose since they aren't likely to go
through every option (or are they?).

--
Justin Koivisto - sp**@koivi.com
PHP POSTERS: Please use comp.lang.php for PHP related questions,
alt.php* groups are not recommended.

Jul 17 '05 #5

P: n/a
On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
The other guy that responded with "Javascript," while less than helpful, was
actually correct. I haven't gotten to try it yet, but here's a page that
appears to explain what I'm attempting to do:

http://www.webxpertz.net/faqs/jsfaq/jsserver.php

The whole application engine is XML based, and designed to run in a Windows
client app or over the web. In the client app I can use window.external
calls to pull whatever I need out of the database to rebuild an element, but
I wasn't sure how I was going to translate that to the web version. I wanted
to avoid using ActiveX controls or plugins since I don't want to be locked
in to IE (although I will require a Javascript enabled browser).

I would catch the onchange event for the first selector, make a quick fetch
for the new set of contact names and id's for the new company selected, then
rebuild the option list in the second selector.

The live support app is doing image.src manipulation to do server pulls,
although I never teased out exactly how they were getting the results. I'll
have to go back now and see if they're doing DOM tricks like this article
talks about.


Interesting stuff - hadn't occurred to me you could get the client to request
and replace Javascript source using Javascript itself - I suppose it's part of
the DOM after all so there's no reason why not.

Provided you know your clients can handle this sort of fiddling it could be
quite useful; this might actually end up applying to something on the intranet
at work that's been bothering me... thanks!

(My reply was overly brief as it looked like it was going offtopic)

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)
Jul 17 '05 #6

P: n/a
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:08********************************@4ax.com...
On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
(My reply was overly brief as it looked like it was going offtopic)


Well, I knew that this live support product was pulling the data out with
PHP, so this seemed like the right place to go. I knew I could get the data
into the document with Javascript, but getting the data looked like it was
going to be a trick. Brief as your answer was, you got me headed in the
right direction. I'll probably give this a shot tonight or tomorrow and I'll
report back with my results.
Jul 17 '05 #7

P: n/a
Hi Philo!

On Thu, 25 Sep 2003 15:43:14 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
Clearly I have to use Javascript for the client piece...

The question is about how to do the server pull to get the fresh data. We
have some clients with very large databases - I don't want to pull down the
entire contacts table just so I can refresh the selector if the company
changes.

Its really a question for comp.lang.javascript and I actually asked it
there 3 weeks ago. Short:

- Use an iframe or different frame
- Reload the frame with javascript and have a javascript array there.
- copy it over into your select-box with javascript

HTH, Jochen


"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:h7********************************@4ax.com.. .
On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
>I've been searching, but apparently not phrasing my search right, so I'm
>going to float a question out here in the meantime...
>
>I'm wondering how to go about refreshing the content of a control (say, a
>selector) without refreshing the page.


Javascript.

--
Andy Hassall (an**@andyh.co.uk) icq(5747695) (http://www.andyh.co.uk)
Space: disk usage analysis tool (http://www.andyhsoftware.co.uk/space)


--
Jochen Daum - CANS Ltd.
PHP DB Edit Toolkit -- PHP scripts for building
database editing interfaces.
http://sourceforge.net/projects/phpdbedittk/
Jul 17 '05 #8

P: n/a
"Jochen Daum" <jo*********@cans.co.nz> wrote in message
news:ek********************************@4ax.com...
Hi Philo! Its really a question for comp.lang.javascript and I actually asked it
there 3 weeks ago. Short:

- Use an iframe or different frame
- Reload the frame with javascript and have a javascript array there.
- copy it over into your select-box with javascript


Our original scheme had been to use a hidden frame, but I was looking for an
alternative. Our live support app was clearly not doing it that way, so I
was trying to figure out how they were.

I did find something that looks promising on another branch of this thread.
Jul 17 '05 #9

P: n/a
I managed to get this tecnique working with my APP, and it's a very nice
trick. I'm pleased to know that I now have a solution that will work both on
the web and from my hosted browser control without resorting to
window.external, hidden frames, or any other kind of weird crap.

I found one other article that walks you through the same technique one step
at a time - it helped me identify a few problems that I had in my
implementation and get the thing running:
http://www.dhtmlcentral.com/tutoria...rials.asp?id=11

"Philo Del Middleston" <bi*******@sobranisoft.com> wrote in message
news:iK*****************@bignews5.bellsouth.net...
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:08********************************@4ax.com...
On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:
(My reply was overly brief as it looked like it was going offtopic)


Well, I knew that this live support product was pulling the data out with
PHP, so this seemed like the right place to go. I knew I could get the

data into the document with Javascript, but getting the data looked like it was
going to be a trick. Brief as your answer was, you got me headed in the
right direction. I'll probably give this a shot tonight or tomorrow and I'll report back with my results.

Jul 17 '05 #10

P: n/a
I just noticed that the URL got munged. Here it is again:

http://www.dhtmlcentral.com/tutorial...ials.asp?id=11

Someone pointed out to me that this article missed the trick to avoid
caching by appending the date to the end of the script.src value as a GET
argument, so watch out for that.

"Philo Del Middleston" <bi*******@sobranisoft.com> wrote in message
news:rk******************@bignews4.bellsouth.net.. .
I managed to get this tecnique working with my APP, and it's a very nice
trick. I'm pleased to know that I now have a solution that will work both on the web and from my hosted browser control without resorting to
window.external, hidden frames, or any other kind of weird crap.

I found one other article that walks you through the same technique one step at a time - it helped me identify a few problems that I had in my
implementation and get the thing running:
http://www.dhtmlcentral.com/tutoria...rials.asp?id=11

"Philo Del Middleston" <bi*******@sobranisoft.com> wrote in message
news:iK*****************@bignews5.bellsouth.net...
"Andy Hassall" <an**@andyh.co.uk> wrote in message
news:08********************************@4ax.com...
On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
<bi*******@sobranisoft.com> wrote:

(My reply was overly brief as it looked like it was going offtopic)


Well, I knew that this live support product was pulling the data out with PHP, so this seemed like the right place to go. I knew I could get the

data
into the document with Javascript, but getting the data looked like it was going to be a trick. Brief as your answer was, you got me headed in the
right direction. I'll probably give this a shot tonight or tomorrow and

I'll
report back with my results.


Jul 17 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.