How to change a button from another function?

Posted by Fernando SBS on Stack Overflow See other posts from Stack Overflow or by Fernando SBS
Published on 2010-05-10T02:33:39Z Indexed on 2010/05/10 5:44 UTC
Read the original article Hit count: 218

Filed under:
|
|
var ButtonFarmAtivada = new Array();

function X() {
var tableCol = dom.cn("td"); //cell 0

//create start checkbox button

ButtonFarmAtivada[index] = createInputButton("checkbox", index);

ButtonFarmAtivada[index].name = "buttonFarmAtivada_"+index;

ButtonFarmAtivada[index].checked = GM_getValue("farmAtivada_"+index, true);

FM_log(3,"checkboxFarm "+(index)+" = "+GM_getValue("farmAtivada_"+index));

ButtonFarmAtivada[index].addEventListener("click", function() {
       rp_farmAtivada(index);
}, false);

tableCol.appendChild(ButtonFarmAtivada[i]);

tableRow.appendChild(tableCol); // add the cell

}

1) is it possible to create the button inside an array as I'm trying to do in that example? like an array of buttons?

2) I ask that because I will have to change this button later from another function, and I'm trying to do that like this (not working):

function rp_marcadesmarcaFarm(valor) {

  var vListID = getAllVillageId().toString();

  FM_log(4,"MarcaDesmarcaFarm + vListID="+vListID);

  var attackList = vListID.split(",");

     for (i = 0; i <= attackList.length; i++) {
         FM_log(3, "Marca/desmarca = "+i+" "+buttonFarmAtivada[i].Checked);
         ButtonFarmAtivada[i].Checked = valor;
     };
};

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about array