LoL, don’t know if the title is very clear but here is my code:
!!! FORGOT TO SAY $field() is a shortcurt for document.getElementByID()
[CODE]function contador(campo,frases) {
this.flg = 0;
this.fld = campo;
this.frs = frases;
this.init = startMsg;
this.stop = stopMsg;
}
function startMsg() {
if (this.flg == 0) {this.flg = 1;this.pos = 0;}
$field(this.fld).innerHTML = this.frs[this.pos++];
if (this.pos == 4) this.pos = 0;
switch (this.fld) {
case “c_menu”: this.count = setTimeout(“cont_menu.init()”,500); break;
case “id_disp”: this.count = setTimeout(“cont_id.init()”,500); break;
case “cnpj_disp”: this.count = setTimeout(“cont_cnpj.init()”,500); break;
case “cpf_disp”: this.count = setTimeout(“cont_cpf.init()”,500); break;
case “login_disp”: this.count = setTimeout(“cont_log.init()”,500); break;
case “data_fua”: this.count = setTimeout(“cont_dfua.init()”,500); break;
case “data_fia”: this.count = setTimeout(“cont_dfia.init()”,500); break;
}
}
function stopMsg() {
clearTimeout(this.count);
$field(this.fld).innerHTML = “”;
this.flg = 0;
}
the cont_*.init() are instances of the contador “class”. I did this way cause I don’t know a way of using the setTimeout to call the method of the original instance. It works this way, but I’m a freak of nice coding.
Already tried
[CODE]
this.count = setTimeout(“init()”,500);
this.count = setTimeout(this.init,500);
this.count = setTimeout(“startMsg()”,500);
this.count = setTimeout(this.startMsg,500);
Someone has a suggestion?