View Full Version : Populating Menus

03-08-2008, 04:52 PM

I've a function that dynamically populates a menu when a button is clicked, (the menu is populated with checkbox items) this works fine, but I then want to use these checkbox items as input controls, how can I add this functionality to the items as they are only generated when the user clicks a button?


This is the code that populates the menu

var menu = document.getElementById("tagmenu");

for (var j = 0; j < x.length; j++)

t = x[j].getAttribute("content");
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
var temp = document.createElementNS(XUL_NS, "menuitem"); // create a new XUL menuitem

temp.setAttribute("label", t);
temp.setAttribute("type", "checkbox");


And the code that uses the takes the items from the menu to the output area (a textbox, but currently this just works for already defined menu items).

var x= document.getElementById("menuitem");
y = x.getAttribute("label");
if (x.checked = true)
var t = document.getElementById("get-tag");
t.setAttribute("value", y);