Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:45:25+00:00 2026-05-27T01:45:25+00:00

So I have this code running pretty well.. lately.. and I need to select

  • 0

So I have this code running pretty well.. lately.. and I need to select an option of a select list (only one that has GET method) here is the code I am using

require 'mechanize'
require 'logger'
agent = Mechanize.new{|a| a.log = Logger.new(STDERR) }
agent.read_timeout = 60
def add_cookie(agent, uri, cookie)
uri = URI.parse(uri)
Mechanize::Cookie.parse(uri, cookie) do |cookie|
agent.cookie_jar.add(uri, cookie)
end
end
page = agent.get "http://www.webpage.com"
form = page.forms.first
form.correo_ingresar = "user"
form.password = "password"
page = agent.submit form
myarray = page.body.scan(/SetCookie\(\"(.+)\", \"(.+)\"\)/)
myarray.each{|line| add_cookie agent, 'http://www.sistemasaplicados.com.mx', "#{line[0]}=#{line[1]}"}

add_cookie(agent, 'http://www.webpage.com.mx', "tampag=1000; path=/; domain=www.webpage.com.mx")
add_cookie(agent, 'http://www.webpage.com.mx', "codigoseccion_buscar=; path=/; domain=www.webpage.com.mx")
add_cookie(agent, 'http://www.webpage.com.mx', "codigolinea_buscar=; path=/; domain=www.webpage.com.mx")
add_cookie(agent, 'http://www.webpage.com.mx', "codigomarca_buscar=; path=/; domain=www.webpage.com.mx")
add_cookie(agent, 'http://www.webpage.com.mx', "textobuscar=; path=/; domain=www.webpage.com.mx")
add_cookie(agent, 'http://www.webpage.com.mx', "orden_articulos=existencias asc; path=/; domain=www.sistemasaplicados.com.mx")

page = agent.get "http://www.webpage.com.mx/tienda/articulos.php"
busqueda = page.forms.first
resultado = agent.submit busqued
tamanio = resultado.form_with(:method => "GET")
oneselect = resultado.form_with(:name => "tamano")

so I already used variable tamanio to show that select list form:

#<Mechanize::Form
{name nil}
{method "GET"}
{action "http://www.webpage.com.mx/tienda/articulos.php"}
{fields
#<Mechanize::Form::SelectList:0x2233350
 @name="tamano",
 @node=
 #(Element:0x11199d8 {
  name = "select",
   attributes = [
     #(Attr:0x10f30c8 {
       name = "style",
       value = "font-family: verdana; font-size: 10px; color:black;"
       }),
     #(Attr:0x10f30bc { name = "name", value = "tamano" }),
     #(Attr:0x10f30b0 {
       name = "onchange",
       value = "if (confirm('Haz solicitado modificar la cantidad de articulos por p\u00E1gina. Este cambio permanecer\u00E1 hasta que cierres la sesi\u00F3n o solicites el cambio nuevamente. \u00BFDeseas continuar?')){SetCookie('tampag',this.value); document.location='/tienda/articulos.php';} else {return;} "
       }),
      #(Attr:0x10f30a4 {
       name = "title",
       value = "Cambiar cantidad de art\u00EDculos por p\u00E1gina"
       })],
   children = [
     #(Element:0x11197e0 {
       name = "option",
      attributes = [
        #(Attr:0x10f1a0c { name = "value", value = "10" }),
        #(Attr:0x10f1a00 { name = "selected", value = "selected" })],
      children = [ #(Text "10")]
      }),
    #(Element:0x1119780 {
      name = "option",
      attributes = [ #(Attr:0x10f0a40 { name = "value", value = "20" })],
      children = [ #(Text "20")]
      }),
    #(Element:0x1119720 {
      name = "option",
      attributes = [ #(Attr:0x10efed0 { name = "value", value = "30" })],
      children = [ #(Text "30")]
      }),
    #(Element:0x11196c0 {
      name = "option",
      attributes = [ #(Attr:0x10ef354 { name = "value", value = "40" })],
      children = [ #(Text "40")]
      }),
    #(Element:0x1119660 {
      name = "option",
      attributes = [ #(Attr:0x10ee73c { name = "value", value = "50" })],
      children = [ #(Text "50")]
      }),
    #(Element:0x1119600 {
      name = "option",
      attributes = [ #(Attr:0x10eda04 { name = "value", value = "100" })],
      children = [ #(Text "100")]
      }),
    #(Element:0x11195a0 {
      name = "option",
      attributes = [ #(Attr:0x10ecec4 { name = "value", value = "500" })],
      children = [ #(Text "500")]
      }),
    #(Element:0x1119540 {
      name = "option",
      attributes = [ #(Attr:0x10ec360 { name = "value", value = "1000" })],
      children = [ #(Text "1000")]
      })]
   }),
@options=[10, 20, 30, 40, 50, 100, 500, 1000],
@value=[]>}
{radiobuttons}
{checkboxes}
{file_uploads}
{buttons}>

Looks like the select list is a nested form so, I tried:

selectlist.value = selectlist.options.first.value (replacing selectlist with the variable tamanio)

also tried adding a new node to the existing selectlist form with:

oneselect.new("select","1000")

am I missing something here?..

  • 1 1 Answer
  • 2 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:45:26+00:00Added an answer on May 27, 2026 at 1:45 am

    I think you’re confused in general, for an answer I’ll just give you some notes and hope it helps:

    • There’s no such thing as nested forms
    • A SelectList is not a form, it’s a form element, or a form control
    • You can access a SelectList by calling a method on the form that it’s
      an element of:

       select_list = form.field_with(:name => "tamano")
      
    • When a form’s method is GET, it’s often easier to just construct the
      url and use agent.get

      url = "http://www.mysite.com/page?var=#{select_list.value}"
      agent.get url
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this code running great in ff, opera and chrome: <script type=text/javascript> $(document).ready(function(){
Code is not running on .click when I have this: $(.cancel).click(function() { alert(got here);
I'm a beginner with jdbc ... I have a problem running this code :
I have an EntityFramework project running off MySql that runs great locally as well
I have this code for doing an ajax request to a webservice: var MyCode
I have this code: $(div[id^='intCell']).mouseover(function() { $(this).css({ border:,1px solid #ff097c}); }).mouseout(function() { $(this).css({border:,1px solid
I have this code to show a map using the Virtual Earth API: <script
I have this code here, which is intended to allow any type of arguments:
I have this code in my forms.py : from django import forms from formfieldset.forms
I have this code so I can grab the values ind the dataset before

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.