Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You need to modify the DOM rapresenting your menupopup. For example:</p> <pre><code>&lt;menulist&gt; &lt;menupopup id="myMenuPopup"&gt; &lt;menuitem id="firstItem" label="Mozilla" value="http://mozilla.org"/&gt; &lt;menuitem id="secondItem" label="Slashdot" value="http://slashdot.org"/&gt; &lt;menuitem id="thirdItem" label="Sourceforge" value="http://sf.net"/&gt; &lt;/menupopup&gt; &lt;/menulist&gt; </code></pre> <p>Now if you want to add another item:</p> <pre><code>var myMenuPopup = document.getElementById("myMenuPopup"); var newItem = document.createElement("menuitem"); newItem.setAttribute("id", "anotherItem"); myMenuPopup.appendChild(newItem); </code></pre> <p>If you want to remove an item:</p> <pre><code>var itemToRemove = myMenuPopup.getElementById("anotherItem"); myMenuPopup.appendChild(itemToRemove); </code></pre> <p>Here you can find much more:</p> <p><a href="https://developer.mozilla.org/en/Dynamically_modifying_XUL-based_user_interface" rel="nofollow noreferrer">https://developer.mozilla.org/en/Dynamically_modifying_XUL-based_user_interface</a></p> <p><strong>Edit:</strong></p> <p>I assume thet your function returns an array of names:</p> <pre><code>var nameLists = yourFunction(); for (var i=0; i&lt;nameList.length; i++){ var newItem = document.createElement("menuitem"); newItem.setAttribute("label", nameList[i]); newItem.setAttribute("id", "item" + i); myMenuPopup.appendChild(newItem); } </code></pre> <p>I think is better if you call the function that make items <strong>before</strong> user click on menupopup, not on the event invocation, because if you have many items it may takes a little to construct the items list. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload