Professional Web Applications Themes

Dynamically Refreshing a DIV or other control from the Server - PHP Development

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 ...

  1. #1

    Default Dynamically Refreshing a DIV or other control from the Server

    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...


    Philo Del Middleston Guest

  2. #2

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
    <bitbucketsobranisoft.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 (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  3. #3

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    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" <andyandyh.co.uk> wrote in message
    news:h7g6nvk09299osl8c3tgm668gar1lke43c4ax.com...
    > On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
    > <bitbucketsobranisoft.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 (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    > Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])

    Philo Del Middleston Guest

  4. #4

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    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 - [email]spamkoivi.com[/email]
    PHP POSTERS: Please use comp.lang.php for PHP related questions,
    alt.php* groups are not recommended.

    Justin Koivisto Guest

  5. #5

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    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:

    [url]http://www.webxpertz.net/faqs/jsfaq/jsserver.php[/url]

    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 - [email]spamkoivi.com[/email]
    > PHP POSTERS: Please use comp.lang.php for PHP related questions,
    > alt.php* groups are not recommended.
    >

    Philo Del Middleston Guest

  6. #6

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
    <bitbucketsobranisoft.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:
    >
    >[url]http://www.webxpertz.net/faqs/jsfaq/jsserver.php[/url]
    >
    >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 (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    Andy Hassall Guest

  7. #7

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    "Andy Hassall" <andyandyh.co.uk> wrote in message
    news:08p6nv0fifbdpvn4hunktqof11ssvfn0p14ax.com...
    > On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
    > <bitbucketsobranisoft.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 doent 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.


    Philo Del Middleston Guest

  8. #8

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    Hi Philo!

    On Thu, 25 Sep 2003 15:43:14 -0400, "Philo Del Middleston"
    <bitbucketsobranisoft.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" <andyandyh.co.uk> wrote in message
    >news:h7g6nvk09299osl8c3tgm668gar1lke43c4ax.com.. .
    >> On Thu, 25 Sep 2003 15:18:28 -0400, "Philo Del Middleston"
    >> <bitbucketsobranisoft.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 (andyandyh.co.uk) icq(5747695) ([url]http://www.andyh.co.uk[/url])
    >> Space: disk usage ysis tool ([url]http://www.andyhsoftware.co.uk/space[/url])
    >
    --
    Jochen Daum - CANS Ltd.
    PHP DB Edit Toolkit -- PHP scripts for building
    database editing interfaces.
    [url]http://sourceforge.net/projects/phpdbedittk/[/url]
    Jochen Daum Guest

  9. #9

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    "Jochen Daum" <jochen.daumcans.co.nz> wrote in message
    news:ek07nvc6fjkp4v7vhakc2ss4fn4m1i2chm4ax.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.


    Philo Del Middleston Guest

  10. #10

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    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:
    [url]http://www.dhtmlcentral.com/tutoria...rials.asp?id=11[/url]

    "Philo Del Middleston" <bitbucketsobranisoft.com> wrote in message
    news:iKJcb.22715$iO.1120bignews5.bellsouth.net...
    > "Andy Hassall" <andyandyh.co.uk> wrote in message
    > news:08p6nv0fifbdpvn4hunktqof11ssvfn0p14ax.com...
    > > On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
    > > <bitbucketsobranisoft.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 doent 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.
    >
    >

    Philo Del Middleston Guest

  11. #11

    Default Re: Dynamically Refreshing a DIV or other control from the Server

    I just noticed that the URL got munged. Here it is again:

    [url]http://www.dhtmlcentral.com/tutorials/tutorials.asp?id=11[/url]

    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" <bitbucketsobranisoft.com> wrote in message
    news:rkYdb.10637$T65.6562bignews4.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:
    > [url]http://www.dhtmlcentral.com/tutoria...rials.asp?id=11[/url]
    >
    > "Philo Del Middleston" <bitbucketsobranisoft.com> wrote in message
    > news:iKJcb.22715$iO.1120bignews5.bellsouth.net...
    > > "Andy Hassall" <andyandyh.co.uk> wrote in message
    > > news:08p6nv0fifbdpvn4hunktqof11ssvfn0p14ax.com...
    > > > On Thu, 25 Sep 2003 17:52:44 -0400, "Philo Del Middleston"
    > > > <bitbucketsobranisoft.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 doent 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.
    > >
    > >
    >
    >

    Philo Del Middleston Guest

Similar Threads

  1. Replies: 0
    Last Post: December 8th, 09:32 AM
  2. Refreshing application dynamically to use the latest satellite assembly
    By Yasutaka Ito in forum ASP.NET Building Controls
    Replies: 0
    Last Post: August 16th, 08:05 AM
  3. Refreshing web control after sub-property change
    By Bruce Parker in forum ASP.NET Building Controls
    Replies: 1
    Last Post: April 28th, 12:55 AM
  4. Dynamically changing server control defaults
    By Scott C. in forum ASP.NET Building Controls
    Replies: 0
    Last Post: March 4th, 07:31 PM
  5. Adding Server Control dynamically in CodeBehind
    By Serge in forum ASP.NET Building Controls
    Replies: 3
    Last Post: September 23rd, 03:38 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139