wood burning stoves*
The moose likes HTML, CSS and JavaScript and the fly likes Dynamically change events Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "Dynamically change events" Watch "Dynamically change events" New topic
Author

Dynamically change events

R Mousavi
Greenhorn

Joined: Sep 27, 2005
Posts: 7
Hi,

I am trying to change the onclick event of a particular element in my html code dynamically. I know that this can be done if there is no parameters by simply omitting the brackets at the end. However, I'm having problems getting it to work when the method takes parameters. Does anybody know how to do this?

Thanks,

Reza
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
------.onclick = function(){alert('a');}

Eric
R Mousavi
Greenhorn

Joined: Sep 27, 2005
Posts: 7
Thanks for the reply. I have tried your suggestion, however it seems that it will not work for me as it tries to evaluate the parameters of the function when it is run. I need the parameters to be evaluated when the events are being set and the function run when the event occurs, looking at the following piece of code might explain further what im trying to do.

The function below takes the tag and the class you are using and changes all of their onclick events to perform a specific action. I have also tried using evall(elems[i].id), but this will make all of the ids equal to the last one passed.


(p.s. the kk on the onclickk and ll on evall are because it wouldnt let me submit the post)
Thanks,
Reza
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Dynamically change events
 
Similar Threads
with Java: how to update a row in sybase with string having a single quote
Dynamic JTree Components
Sql statement
How to detect if a request value contains a String or a Stringarray
dynamically loading a class