javascript - HTMLButtonObject stored in an array -


my current code directly below. works except button function.

the 1 line giving me issues

var tesbut = new onclickfunc(buttons[g], 'testbuttloc'); 

line. believe because cannot make buttons[g] htmlbuttonelement why have line.

buttons[g].setattribute("type", "htmlbuttonelement"); 

i believe need line directly above because whenever use

var tesbut = new onclickfunc(testbutt, 'testbuttloc'); 

it works. (these names of variables declared in xml) so, there advice?

     var buttons = [];      var subbuttons = [];                 for(var mainsplunkcount = 0; mainsplunkcount<mx.length; mainsplunkcount++){             buttons[mainsplunkcount] = mx[mainsplunkcount].getelementsbytagname("button")[0].childnodes[0].nodevalue;                    subbuttons[mainsplunkcount] =mx[mainsplunkcount].getelementsbytagname("buttonloc")[0].childnodes[0].nodevalue;             mainnewstat.id = mainstatus[mainsplunkcount];             $("<div />", { "class":"main_category", id:"product"+group[mainsplunkcount] })             $("<button />", { id:buttons[mainsplunkcount] })             //divs work             .append($('</button>'))             .append($('</div>'))             .appendto(main_sort[mainsplunkcount]);             $("<div />", { id:subbuttons[mainsplunkcount], "class" : "hidden"})             .append($('<div class="group"><font size="2">' + maingroup[mainsplunkcount] + '</div></div>'))             .append($('</div>'))             .appendto(main_sort[mainsplunkcount]);       }           //dropdown submenus of menus       var onclickfunc = function(button, newpost){         button.onclick = function(){            var div = document.getelementbyid(newpost);            if(div.style.display !== 'none'){                div.style.display = 'none';            } else{               div.style.display = 'inline';            }           };       };        for(var g = 0; g<mx.length; g++){         buttons[g].setattribute("type", "htmlbuttonelement");         var tesbut = new onclickfunc(buttons[g], 'testbuttloc');       } 

xml code

<maincontainer>     <group>test</group>     <inout>test</inout>     <criticality>test</criticality>     <callnumber>6</callnumber>     <location>sortall5</location>     <statusname>testt</statusname>     <button>testbutt</button>     <buttonloc>testbuttloc</buttonloc> 


Comments

Popular posts from this blog

searchKeyword not working in AngularJS filter -

sequelize.js - Sequelize: sort by enum cases -

user interface - how to replace an ongoing process of image capture from another process call over the same ImageLabel in python's GUI TKinter -