From: Aaron Patterson Date: 2006-08-06T03:56:47+09:00 Subject: Re: Mechanize On Sat, Aug 05, 2006 at 04:20:09PM +0900, barjunk wrote: > Gregory Brown wrote: > > On 8/4/06, barjunk wrote: > > > > [snip] > > > Not a reference, but here is some code from my freshmeat automation > > that deals with select lists in a form field > > > > s = form.field("add_release[release_focus_name]") The variable "s" is a SelectList class which represents a "select" html tag. > > s.value = s.options[5].value A SelectList class has many Options associated with it. An Option represents an "option" tag. Here Gregory is picking one of the options and setting it as the value for this select list. > > > > t = form.field("add_release[hide_from_frontpage]") > > t.value = t.options[0].value > > what do add_release[release_focus_name] and the add_release etc...stand > for? "add_release[release_focus_name]" is the name of the select field. Gregory is probably dealing HTML that looks something like this: If you wanted to look at the text for each option, your code might look something like this (using the variables Gregory had): s.options.each { |o| puts "Text: '#{o.text}' Value: '#{o.value}'" } Make sure to check out the RDoc for WWW::Mechanize::SelectList and WWW::Mechanize::Option at http://mechanize.rubyforge.org/ I hope this helps! --Aaron