choosing correct form according to form input's name
<p>I want to submit forms in multiple websites. Usually I can't exactly know the form name or form id, but I know the input name that I want to submit.</p>

<p>Let's say there is a website which has couple of forms inside it. My code should check all of the forms, if one of them has a input value named "birthday" it will submit that form. If multiple forms has it, it will submit them all.</p>

<p>How can I achieve this?</p>

<p>You are gonna need to use an <a href="http://stackoverflow.com/a/9884259/6209196">iterator</a> to check all the forms in the website. In this case we will be using <code>for</code>. But this doesn't let us know about which form we are working on, it just lets us use it. So we are going to assign 0(the first form's ID) to a variable and add 1 to it as we change forms when a new iteration/loop starts.</p>

<pre><code>currentForm = 0
for form in br.forms(): # For every form in the website
        currentForm += 1 # Add 1 to the current form so that the script knows which form we will be working next
        if not forms.find_control(name = "birthday"): # If the form isn't about birthday
                continue # Go to the next iteration / loop ignoring the statements below
        br.select_form(nr = currentForm) # Select the birthday form
        br.form["birthday"] = "Fill this with what you want" # Writing to the form
        br.submit() # Submit the working form
</code></pre>

<p>Note: <code>x += y</code> is equal to <code>x = x + y</code></p>

python mechanize