| Class | WWW::Mechanize::SelectList |
| In: |
lib/mechanize/form_elements.rb
|
| Parent: | MultiSelectList |
This class represents a select list or drop down box in a Form. Set the value for the list by calling SelectList#value=. SelectList contains a list of Option that were found. After finding the correct option, set the select lists value to the option value:
selectlist.value = selectlist.options.first.value
Options can also be selected by "clicking" or selecting them. See Option
# File lib/mechanize/form_elements.rb, line 179
179: def initialize(name, node)
180: super(name, node)
181: if selected_options.length > 1
182: selected_options.reverse[1..selected_options.length].each do |o|
183: o.unselect
184: end
185: end
186: end
# File lib/mechanize/form_elements.rb, line 188
188: def value
189: value = super
190: if value.length > 0
191: value.last
192: elsif @options.length > 0
193: @options.first.value
194: else
195: nil
196: end
197: end