Jump to content

[SOLVED?] DOM "name" property reading the wrong node


Recommended Posts

Hi,

this is probably another one of my newbie easy questions. Here's the image of the table/form I'm trying to control.

https://docs.google.com/file/d/0ByUpE9M4BFXIMjc5aU1ubklYZG8/edit

The goal is to set values of the two date input boxes and click submit.

Here's the code I've got so far to identify the DOM elements:

#include <IE.au3>

Local $oIE1 = _IECreate("http://lomacorvu/corvucgi/cvhtmsrv.exe?file=/Loma/Purchasing/UK_PO_Receipts_by_Period.qry&showprompts=1")
Local $tagINPUT = _IETagNameGetCollection($oIE1, "input")

For $oInput In $tagINPUT
ConsoleWrite($oInput.name & @CRLF)
If $oInput.name = "prompt_1" Then
$oInput_1 = $oInput
ElseIf $oInput.name = "prompt_2" Then
$oInput_2 = $oInput
Else
ContinueLoop
EndIf

#cs
Switch $oInput.name
Case "prompt_1"
$oInput_1 = $oInput
Case "prompt_2"
$oInput_2 = $oInput
EndSwitch
#ce
Next

MsgBox(0, "", $oInput_1.name & @CRLF & $oInput_2.name & @CRLF & " Prompt 2 Value is: " & $oInput_2.value & @CRLF & " Prompt 1 Value is: " & $oInput_1.value)

My problem is that instead of the first input box named: "prompt_1", I get the submit element named "0"

I'm not sure what I'm doing wrong. I'm only starting to learn this.

regards

Daniel

Here's the result after running it:

https://docs.google.com/open?id=0ByUpE9M4BFXITGRhVHo1M0pzT1U

Edited by DanielTyrkiel
Link to comment
Share on other sites

I think I've sorted it myself again...

Here's what I've added:

$oInput_1 = _IETagNameGetCollection($oIE1, "input", 6)
$oInput_2 = _IETagNameGetCollection($oIE1, "input", 7)

MsgBox(0, "", $oInput_1.name & @CRLF & $oInput_2.name & @CRLF & " Prompt 2 Value is: " & $oInput_2.value & @CRLF & " Prompt 1 Value is: " & $oInput_1.value)

I've used the console output to see the index numbers for the values

nevermind...

Link to comment
Share on other sites

Your URL is invalid for me, so I can't look at the page, but my guess is that a simple change would fix your initial logic. You need to force a STRING comparison when you are looking for the .names... If there is no name attribute, you get a numeric 0 returned and your comparison, If 0 = "prompt_1", does a numeric comparison which converts "prompt_1" to a number first (and that would be 0). 0 = 0 is True.

So, use

If String($oInput.name) = "prompt_1" Then

Dale

Free Internet Tools: DebugBar, AutoIt IE Builder, HTTP UDF, MODIV2, IE Developer Toolbar, IEDocMon, Fiddler, HTML Validator, WGet, curl

MSDN docs: InternetExplorer Object, Document Object, Overviews and Tutorials, DHTML Objects, DHTML Events, WinHttpRequest, XmlHttpRequest, Cross-Frame Scripting, Office object model

Automate input type=file (Related)

Alternative to _IECreateEmbedded? better: _IECreatePseudoEmbedded  Better Better?

IE.au3 issues with Vista - Workarounds

SciTe Debug mode - it's magic: #AutoIt3Wrapper_run_debug_mode=Y

Doesn't work needs to be ripped out of the troubleshooting lexicon. It means that what you tried did not produce the results you expected. It begs the questions 1) what did you try?, 2) what did you expect? and 3) what happened instead?

Reproducer: a small (the smallest?) piece of stand-alone code that demonstrates your trouble

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...