# Javascript Event Handler for Chat App

**URL:** <https://www.ruby-forum.com/t/javascript-event-handler-for-chat-app/59625>\
**Category:** Rails\
**Created:** [May 4, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/javascript-event-handler-for-chat-app/59625 "2006-05-04T20:16:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [May 4, 2006, 8:16pm UTC](https://www.ruby-forum.com/t/javascript-event-handler-for-chat-app/59625/1 "2006-05-04T20:16:38Z")

</div>

Hi guys,

I’m stuck with this perplexing problem of Javascript and periodic  
updater. I’m trying to do a chat application and it’s an issue of  
holding on the the div id. I have no problems when the user clicks on a  
submit button to sends a message to the presence server. On the other  
side of it though, I’m using periodicupdater to poll the server for the  
messages to act as the listener, the problem is that bec I can’t hold on  
to the div id, the messages being retrieved from the presence server are  
being broadcasted to all of the divs.

I know that the only way to capture the div id is if an event was  
triggered. So to try and solve the problem of the listener, I had  
thought of creating the listener into a form where a “hidden button”  
will actually be triggered periodically. Holding on to the button allows  
me to hold on to the div element. But with this solution, is there a way  
for me to periodically update that button? How would I create my  
periodic update if my server listener app was a form and my event was a  
hidden button…or is there a way to do this aside from using an  
invisible button?

any help would be very much appreciated!

thanks,

Bing

---

<div class="post-metadata">

**Author:** ![sombrero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/94ad74/32.png) [@sombrero](https://www.ruby-forum.com/u/sombrero)\
**Post date:** [May 5, 2006, 4:56am UTC](https://www.ruby-forum.com/t/javascript-event-handler-for-chat-app/59625/2 "2006-05-05T04:56:48Z")

</div>

anyone?

Hi guys,

I’m stuck with this perplexing problem of Javascript and periodic  
updater. I’m trying to do a chat application and it’s an issue of  
holding on the the div id. I have no problems when the user clicks on a  
submit button to sends a message to the presence server. On the other  
side of it though, I’m using periodicupdater to poll the server for the  
messages to act as the listener, the problem is that bec I can’t hold  
on  
to the div id, the messages being retrieved from the presence server  
are  
being broadcasted to all of the divs.

I know that the only way to capture the div id is if an event was  
triggered. So to try and solve the problem of the listener, I had  
thought of creating the listener into a form where a “hidden button”  
will actually be triggered periodically. Holding on to the button  
allows  
me to hold on to the div element. But with this solution, is there a  
way  
for me to periodically update that button? How would I create my  
periodic update if my server listener app was a form and my event was a  
hidden button…or is there a way to do this aside from using an  
invisible button?

any help would be very much appreciated!

thanks,

Bing
