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

  • SEARCH
  • Home
  • 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 6873591
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:05:16+00:00 2026-05-27T04:05:16+00:00

Here is the form: <p><label for=version_id>Version</label> <select id=version_id name=version_id><option></option> <option value=value1>2.1.1</option> <option value=value2>2.1.2</option> <option

  • 0

Here is the form:

<p><label for="version_id">Version</label>
<select id="version_id" name="version_id"><option></option>
<option value="value1">2.1.1</option>
<option value="value2">2.1.2</option>
<option value="value3">2.1.3</option>
<option value="value4">2.1.4</option></select></p>

My python code:

import mechanize
br = mechanize.Browser()
br.open('http://www.example.com/html/html_forms.asp')
br["version_id"] = ["value2"] # works
br["version_id"] = ["2.1.2"] # don't work

The error message:

File "build/bdist.macosx-10.7-intel/egg/mechanize/_form.py", line 2782, in __setitem__
File "build/bdist.macosx-10.7-intel/egg/mechanize/_form.py", line 1977, in __setattr__
File "build/bdist.macosx-10.7-intel/egg/mechanize/_form.py", line 1998, in _set_value
File "build/bdist.macosx-10.7-intel/egg/mechanize/_form.py", line 2021, in _single_set_value
File "build/bdist.macosx-10.7-intel/egg/mechanize/_form.py", line 2006, in _get_items
mechanize._form.ItemNotFoundError: insufficient items with name '2.1.2'

My script just know about the “2.1.2” var, how could I set the select value by using “2.1.2” not “value2”?

  • 1 1 Answer
  • 0 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-27T04:05:17+00:00Added an answer on May 27, 2026 at 4:05 am

    I think you can get there by parsing the form. I did a quick search to find a site with a html dropdown box on the page, so you could directly try the below example.

    >>> import mechanize
    >>> br = mechanize.Browser()
    >>> br.open("http://www.htmlcodetutorial.com/linking/linking_famsupp_114.html")
    <response_seek_wrapper at 0x2b4b238 (...)>
    >>> _, f = br.forms()                      # Select second form
    >>> c = f.find_control('gourl')            # Select dropdown control
    >>> c.set_value_by_label(['Idocs.com'])    # Select the item with this label
    

    If you then look at the selected state, it seems to be selected:

    >>> c.items[2]._selected
    True
    >>> c.set_value_by_label(['Ninth Wonder'])
    >>> c.items[2]._selected
    False
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is my main page code: <form><iframe name=iframe_pic src=iframe.html></iframe></form> Here is my iframe.html: <script
Here is the input form code <tr valign=top> <td align=right class=innertablestyle><font class=normal><strong>Homepage</strong></font></td> <td>&nbsp;</td> <td>
Here is a code form a PHP+MySQL book I am reading and I am
Here's my code: if Request.Form(authorize) <> and request.form(delete) <> true then post_ids = Request.form(authorize)
I'm embedding here a simplified version of a code that is not working for
To give more information I am using the modular form here: http://jqueryui.com/demos/dialog/#modal-form `b(e.target).zIndex` is
The current form is here . It is not complete, and only a couple
Here is a simple form I am using to send XML data in admin_xml.php
here is what my code looks like i have two forms: class Form_1 extends
so here's the problem I have one form, it outputs search results after submit,

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.