3.2.0

multiple events

Hi everybody, i need to set more than an event for the same textarea, but by declaring twice the setevent sentence i get some problems...please give me some help...thanks!
rodrigo talento
April 10,
Can you post the code for what you are trying to do? It sounds like you are overwriting the first event handler with the later one.
Anthony
April 10,
var obj = new AW.HTML.TEXTAREA;
obj.setSize(600, 100);

obj.setEvent("onclick", function(){
if(obj.getContent("html")=="insert your comment here"){
obj.setContent("html", "");
obj.refresh();
obj.element().focus();
}
}

obj.setEvent("onkeypress", function(){
if(event.keyCode == 13){
alert("Don´t use line break");
event.keyCode=0;
}
}

there it is, i think it´s as you say, hope you can help me.
thanks
rodrigo talento
April 11,
This code looks fine, except that it is better to use 'this' instead of 'obj' inside an event handler - otherwise your code will break if there is another variable called 'obj'.
Alex (ActiveWidgets)
April 11,
Thanks, i'll use it that way!..i found the problem in my code, it was a parenthesis problem, i wasn't closing the parenthesis of the setevent sentences, thanks again...
rodrigo talento
April 11,
Rodrigo, you might also want to change this code -
obj.setEvent("onkeypress", function(){
if(event.keyCode == 13){

to
obj.setEvent("onkeypress", function(event){
if(event.keyCode == 13){

I gather that you are using IE. The above change will allow it to work with other browsers.
Anthony
April 12,
Wow!, didn't know that, thanks a lot!
rodrigo talento
April 14,

This topic is archived.

See also:


Back to support forum