Class: Mechanize::Form::SelectList

### Home Classes Methods

### In Files

- lib/mechanize/form/select_list.rb

### Parent

Mechanize::Form::MultiSelectList

### Methods

- ::new
- #query_value
- #value
- #value=

### Files

- EXAMPLES.rdoc
- GUIDE.rdoc
- LICENSE.rdoc
- Manifest.txt
- README.rdoc

### Class/Module Index

Quicksearch

- Mechanize
- Mechanize::ChunkedTerminationError
- Mechanize::ContentTypeError
- Mechanize::Cookie
- Mechanize::CookieCMethods
- Mechanize::CookieDeprecated
- Mechanize::CookieIMethods
- Mechanize::CookieJar
- Mechanize::CookieJarIMethods
- Mechanize::DirectorySaver
- Mechanize::Download
- Mechanize::ElementMatcher
- Mechanize::ElementNotFoundError
- Mechanize::Error
- Mechanize::File
- Mechanize::FileConnection
- Mechanize::FileRequest
- Mechanize::FileResponse
- Mechanize::FileSaver
- Mechanize::Form
- Mechanize::Form::Button
- Mechanize::Form::CheckBox
- Mechanize::Form::Field
- Mechanize::Form::FileUpload
- Mechanize::Form::Hidden
- Mechanize::Form::ImageButton
- Mechanize::Form::Keygen
- Mechanize::Form::MultiSelectList
- Mechanize::Form::Option
- Mechanize::Form::RadioButton
- Mechanize::Form::Reset
- Mechanize::Form::SelectList
- Mechanize::Form::Submit
- Mechanize::Form::Text
- Mechanize::Form::Textarea
- Mechanize::HTTP
- Mechanize::HTTP::Agent
- Mechanize::HTTP::AuthChallenge
- Mechanize::HTTP::AuthRealm
- Mechanize::HTTP::AuthStore
- Mechanize::HTTP::ContentDispositionParser
- Mechanize::HTTP::WWWAuthenticateParser
- Mechanize::Headers
- Mechanize::History
- Mechanize::Image
- Mechanize::Page
- Mechanize::Page::Base
- Mechanize::Page::Frame
- Mechanize::Page::Image
- Mechanize::Page::Label
- Mechanize::Page::Link
- Mechanize::Page::MetaRefresh
- Mechanize::Parser
- Mechanize::PluggableParser
- Mechanize::Prependable
- Mechanize::RedirectLimitReachedError
- Mechanize::RedirectNotGetOrHeadError
- Mechanize::ResponseCodeError
- Mechanize::ResponseReadError
- Mechanize::RobotsDisallowedError
- Mechanize::TestCase
- Mechanize::UnauthorizedError
- Mechanize::UnsupportedSchemeError
- Mechanize::Util
- Mechanize::XmlFile
- HTTP
- HTTP::CookieJar

No matching classes.

# Mechanize::Form::SelectList

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

### Public Class Methods

new(node) click to toggle source

    # File lib/mechanize/form/select_list.rb, line 11
    def initialize node
      super
      if selected_options.length > 1
        selected_options.reverse[1..selected_options.length].each do |o|
          o.unselect
        end
      end
    end

### Public Instance Methods

query_value() click to toggle source

    # File lib/mechanize/form/select_list.rb, line 39
    def query_value
      value ? [[name, value]] : nil
    end

value() click to toggle source

    # File lib/mechanize/form/select_list.rb, line 20
    def value
      value = super
      if value.length > 0
        value.last
      elsif @options.length > 0
        @options.first.value
      else
        nil
      end
    end

value=(new_value) click to toggle source

    # File lib/mechanize/form/select_list.rb, line 31
    def value=(new_value)
      if new_value != new_value.to_s and new_value.respond_to? :first
        super([new_value.first])
      else
        super([new_value.to_s])
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.