Loading ...
Sorry, an error occurred while loading the content.

How to grab YUI Menu Button's ID & Name values

Expand Messages
  • Ruben J. Leon
    Hi all, I m wondering how to grab the ID and Name values of a YUI menu button. I got the following code from the YUI examples and hacked it according to my
    Message 1 of 1 , Aug 24 4:43 AM
    • 0 Attachment
      Hi all,
      I'm wondering how to grab the ID and Name values of a YUI menu button. I got the following code from the YUI examples and hacked it according to my needs. Although.......

      var myName = oMenuItem.value;

      will result in the "value" of the menu. And.......

      var mySelection = oMenuItem.cfg.getProperty("text");

      results in the text value of the menu button. How do I grab the ID and Name attributes and store it in a var?



      Here's some of my code used for the menu button.


      regards,

      James,

      var oButton = new YAHOO.widget.Button({
      type: "menu",
      id: "baseNumber",
      name: "baseNumber",
      label: "<em>Base Number</em>",
      menu: BaseNumberItems,
      container: "baseNumberDiv"
      });


      // "selectedMenuItemChange" event handler for a Button that will set
      // the Button's "label" attribute to the value of the "text"
      // configuration property of the MenuItem that was clicked.
      var onSelectedMenuItemChange = function (event) {

      var oMenuItem = event.newValue;
      this.set("label", ("<em class=\"yui-button-label\">" +
      oMenuItem.cfg.getProperty("text") + "</em>"));

      var mySelection = oMenuItem.cfg.getProperty("text");
      var myName = oMenuItem.value;
      var myQuery = "report=" + myName;


      makeRequest(myQuery);
      };


      // Register a "selectedMenuItemChange" event handler that will sync the
      // Button's "label" attribute to the MenuItem that was clicked.
      oButton.on("selectedMenuItemChange", onSelectedMenuItemChange);
    Your message has been successfully submitted and would be delivered to recipients shortly.