Guuk
Guuk

Reputation: 609

Mechanize - Submit form without click on submit button

Using Mechanize I fill a fom and I want to submit it without clicking on the submit button

<formulaire POST https://WWW/YYY/XXX.php application/x-www-form-urlencoded
  <HiddenControl(type=traitement) (readonly)>
  <HiddenControl(uid=zzzzz) (readonly)>
  <HiddenControl(no_tt=1) (readonly)>
  <SelectControl(ch_ee=[1;2])>
  <SubmitControl(bouton_m=ttttt) (readonly)>
  <SubmitControl(bouton_m=uuuuu) (readonly)>>

In fact the submitting is achieve using onchangefunction for the ch_ee form and it calls a submit function in JS: this.document.formulaire.submit(). I want to do the same thing, i.e. submitting the form without clicking on any SubmitControl button (this button allows to quit the website) but just by submitting using POST.

Upvotes: 2

Views: 1502

Answers (1)

Guuk
Guuk

Reputation: 609

The solution for this issue was to disable the two SubmitControl using the following syntax:

br.select_form(nr=0)
for control in br.form.controls:
    if control.type == "submit":
        control.disabled = True
resp=br.submit()

The line control.disabled=True enables you to disable the two submit button (with label=submit)

Upvotes: 2

Related Questions