popup_menu

popup_menu(name = "", *values)
Instance Public methods

Generate a Select element as a string.

name is the name of the element. The values are the options that can be selected from the Select menu. Each value can be a String or a one, two, or three-element Array. If a String or a one-element Array, this is both the value of that option and the text displayed for it. If a three-element Array, the elements are the option value, displayed text, and a boolean value specifying whether this option starts as selected. The two-element version omits either the option value (defaults to the same as the display text) or the boolean selected specifier (defaults to false).

The attributes and options can also be specified as a hash. In this case, options are specified as an array of values as described above, with the hash key of âVALUESâ.

popup_menu("name", "foo", "bar", "baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="foo">foo</OPTION>
  #   <OPTION VALUE="bar">bar</OPTION>
  #   <OPTION VALUE="baz">baz</OPTION>
  # </SELECT>

popup_menu("name", ["foo"], ["bar", true], "baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="foo">foo</OPTION>
  #   <OPTION VALUE="bar" SELECTED>bar</OPTION>
  #   <OPTION VALUE="baz">baz</OPTION>
  # </SELECT>

popup_menu("name", ["1", "Foo"], ["2", "Bar", true], "Baz")
  # <SELECT NAME="name">
  #   <OPTION VALUE="1">Foo</OPTION>
  #   <OPTION SELECTED VALUE="2">Bar</OPTION>
  #   <OPTION VALUE="Baz">Baz</OPTION>
  # </SELECT>

popup_menu("NAME" => "name", "SIZE" => 2, "MULTIPLE" => true,
            "VALUES" => [["1", "Foo"], ["2", "Bar", true], "Baz"])
  # <SELECT NAME="name" MULTIPLE SIZE="2">
  #   <OPTION VALUE="1">Foo</OPTION>
  #   <OPTION SELECTED VALUE="2">Bar</OPTION>
  #   <OPTION VALUE="Baz">Baz</OPTION>
  # </SELECT>

scrolling_list

doc_ruby_on_rails
2015-03-31 22:02:49
Comments
Leave a Comment

Please login to continue.