Jump to content

Help needed with submitting form


Recommended Posts

Hi.

I have a little problem here with a script.

It worled well so far. But now the destination site has been changed and i be not able to get it work

I have this snippet (see lower down) of the code on the site (Its for semi-automatic get results from NOAA -Ready).

There is a page before. all works fine and then i come to a new page which has been changed. I was successful in choosing the first option, but then I have to submit the form. But it has no name, only input type = submit is given and a value. I tried it by objectid,objectname, index.... nothing worked. There are 8 forms on this page, all built the same way.

<form onsubmit="return false">

<td width="30%">

<select name="m" SIZE="1">

<option selected value="#">---------------Choose A Forecast Dataset----------------</option>

<option value="/ready2-bin/metcycle.pl?product=metgram1&userid=8805&metdata=GFS&mdatacfg=GFS&Lat=47.75&Lon=11.36&x=-1&y=-1&sid=&elev=&sname=&state=&cntry=&map=WORLD&misc=370">GFS Model (0-180h, 3hrly, Global)</option>

<option value="/ready2-bin/metcycle.pl?product=metgram1&userid=8805&metdata=GFSlr&mdatacfg=GFSlr&Lat=47.75&Lon=11.36&x=-1&y=-1&sid=&elev=&sname=&state=&cntry=&map=WORLD&misc=370">GFS Model (180-384h, 12hrly, Global)</option>

</select>

</td><td><input type="SUBMIT" value="Go" onclick ="window.location.href=this.form.elements[0].options[this.form.elements[0].selectedIndex].value"></td>

</form>

How to submit the form with the choosen option (in this example I need option 1 and then submit)?

Best regards in advance

saddleburner

PS: the file I have changed so far i will attach

Link to comment
Share on other sites

I tried to use..

$oIE = _IEAttach("Test Page")
$oForms = _IEFormGetCollection($oIE)

For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.tagname)
Next

however it kicks out this error.

C:\Program Files\AutoIt3\Include\ie.au3 (1075) : ==> The requested action with this object has failed.:

Return SetError($_IEStatus_Success, $oTemp.forms.length, $oTemp.forms)

Return SetError($_IEStatus_Success, $oTemp.forms.length^ ERROR

Bug with autoit? i dont know.

They call me MrRegExpMan

Link to comment
Share on other sites

Since the form has no name, you would have to use the 0-based index to identify it, for example if it's the fourth form on the page:

$oForm = _IEFormGetCollection($oIE, 3)

With the default index (-1) you get a collection of all forms, and you can loop through them as Steveiwonder suggested with a For/In/Next loop. In the loop you would test each form to find the correct one.

Once you get the correct form, you said selecting the option was not a problem?

Does _IEFormSubmit() work when you have the correct $oForm?

:mellow:

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Hi.

No.

The Problem is:

On this mentioned page are 8 forms used as drop down listboxes, every with one or more option selects and all unnamed. Behind every option list field there is a button labeled "Go". After clicking on it a link to another page is followed (the next page will be called)

I was successful to select the right form and to set the right option. Then the click onto the Go-Button should be simulated with which the form should be submitted. And exactly that i got not to work. From the documentation i understood, that better _IEAction than _IEFormSubmit should be used . But neither the one nor the other submits the form.

I tried it with $oForm = _IEFormGetCollection($oIE, 3) as well as with other Tags from the documentation....Nothing worked for me.

Best regards

saddleburner

Link to comment
Share on other sites

I don't think you use the word "form" correctly, and it's clouding the issue. I was referring to the actual "form" tag object in DOM. If you didn't have the correct reference to the form, you wouldn't have been able to set the selection either. How did you get the object reference to the "select" tag? The "input" tag is in the same form and the same technique should have worked. For example:

#include <IE.au3>

; ...

$oForm = _IEFormGetCollection($oIE, 3) ; Or, whatever index works
$oSelect = _IEFormElementGetObjByName($oForm, "m")
_IEFormElementOptionselect($oSelect, "GFS Model (0-180h, 3hrly, Global)", 1, "ByText")
$oInput = _IETagNameGetCollection($oForm, "input", 0) ; assumes 1st instance, index = 0

_IEAction($oInput, "click")

If $oForm works to get $oSelect, it should work to get $oInput also.

If that's not what you're doing, please post the code you used to get $oForm, and then how you used that to operate the option selection successfully.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I tried to use..

$oIE = _IEAttach("Test Page")
$oForms = _IEFormGetCollection($oIE)

For $oForm In $oForms
    MsgBox(0, "Form Info", $oForm.tagname)
Next

however it kicks out this error.

C:\Program Files\AutoIt3\Include\ie.au3 (1075) : ==> The requested action with this object has failed.:

Return SetError($_IEStatus_Success, $oTemp.forms.length, $oTemp.forms)

Return SetError($_IEStatus_Success, $oTemp.forms.length^ ERROR

Bug with autoit? i dont know.

Why does it kick out that error?

Confused?

They call me MrRegExpMan

Link to comment
Share on other sites

Add _IEErrorHandlerRegister() to get more debugging info.

Are the forms inside a Frame or iFrame? If so, you have to drill down to them before getting the collection.

:(

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

  • 4 weeks later...

I don't think you use the word "form" correctly, and it's clouding the issue. I was referring to the actual "form" tag object in DOM. If you didn't have the correct reference to the form, you wouldn't have been able to set the selection either. How did you get the object reference to the "select" tag? The "input" tag is in the same form and the same technique should have worked. For example:

#include <IE.au3>

; ...

$oForm = _IEFormGetCollection($oIE, 3) ; Or, whatever index works
$oSelect = _IEFormElementGetObjByName($oForm, "m")
_IEFormElementOptionselect($oSelect, "GFS Model (0-180h, 3hrly, Global)", 1, "ByText")
$oInput = _IETagNameGetCollection($oForm, "input", 0) ; assumes 1st instance, index = 0

_IEAction($oInput, "click")

If $oForm works to get $oSelect, it should work to get $oInput also.

If that's not what you're doing, please post the code you used to get $oForm, and then how you used that to operate the option selection successfully.

:(

Sorry for the delay in answering.

Thaanks, that worked for me.

Now I have another problem. Hope I`m able to solve it by myself.

Best regards

Herbert

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...