GeeCON Prague 2014*
The moose likes HTML, CSS and JavaScript and the fly likes How do I get an event fired through javascript? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "How do I get an event fired through javascript?" Watch "How do I get an event fired through javascript?" New topic
Author

How do I get an event fired through javascript?

Jayant Raj
Ranch Hand

Joined: Mar 11, 2004
Posts: 42
Hi Friends,

I have a text box 'myTxtBox' to which I have attached a calendar js. When I select a date from the calendar, it gets populated in the text box. But I also
have to call a function 'myFunc', when the value changes in the text box. But the function doesn't get called.

I think when you try to change the value of a text box through JavaScript, it only updates the DOM.

Please help me as to, how can I get the function called when the value of the text box gets changed through JS.

Thanks in advance for any help.
[ May 01, 2006: Message edited by: Bear Bibeault ]

regards,<br />Jayant Raj<br /> <br />SCJP 1.4 [98%]<br />SCWCD 1.4 [91%]<br />SCBCD [In Progress]
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
put the funciton call in your calendar code.

Eric
Jayant Raj
Ranch Hand

Joined: Mar 11, 2004
Posts: 42
Hi Eric,

I thought about putting the function call in the calendar. It is a third party component, so I can't make any changes to that.

I will try explaining the problem, in more detail.

1] I have a calendar control & a read only text field.
2] The user selects a date & it gets populated in the text box.
3] Now since the value in the text box has changed, I make a asynchronous call to a function 'myFunc' using AJAX to validate the date.
4] For this I have a {onchanged = 'myFunc'} for my text box. But this onchanged method doesn't get called.

Please, try to give me some solution.. as I am not very comfortable with JS.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
The function is not going to get called since the onchange is only fired with user interaction. Only thing you can dois build some sort of listener that has a timer on it that checks to see if the value is different.
Eric
 
 
subject: How do I get an event fired through javascript?