# Eruby Mechanize problem when submitting multiple forms

**URL:** <https://www.ruby-forum.com/t/eruby-mechanize-problem-when-submitting-multiple-forms/91214>\
**Category:** Ruby\
**Created:** [April 5, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/eruby-mechanize-problem-when-submitting-multiple-forms/91214 "2007-04-05T18:06:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![unknown](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/u/4bbf92/32.png) [@unknown](https://www.ruby-forum.com/u/unknown)\
**Post date:** [April 5, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/eruby-mechanize-problem-when-submitting-multiple-forms/91214/1 "2007-04-05T18:06:09Z")

</div>

Hi All,

I am using eruby and Mechanize to submit forms on a website. The first  
form  
has a “Accept Agreement” checkbox, when user checks this checkbox and  
submits this form, another form shows up which is the actual input  
form.

When using eruby and Mechanize, I get the first form, check the accept  
checkbox and then get the second form and then populate the fields in  
the  
second form. But when I submit the second form, it shows a page  
saying “You  
did not accept the agreement on first form”. So basically the Accept  
on  
first form is not getting passed while submitting the second form.

here is what I am doing:

agent = WWW::Mechanize.new  
page = agent.get(“[http://www.abc.com](http://www.abc.com)”)  
form = page.forms[1] // get first form  
form.checkboxes.name(‘accept’).check // accept agreement  
page = agent.submit(form) // submit first form  
nextform = page.forms[1] //get next form  
nextform.first\_name = “myname” // populate second form  
nextform.last\_name = “mylastname”  
page = agent.submit(nextform) // submit second form  
puts page.body

Does anyone know how can I get this to work ?
