Jump to content
Sign in to follow this  
zhaeldd

IE clicking second button while first one has same value

Recommended Posts

zhaeldd

So the problem is that I would like to click the second button while both buttons have the same value. With the code I'm using i can only get it to work with the first button. This is the code I'm using: 

$oLinks = _IETagNameGetCollection($oIE, "input")
         For $oLink In $oLinks
            If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then
            $oLink = $oLink
            _IEAction($oLink, "click")
            ExitLoop
            EndIf
         Next

Buttons source code: 

<div id="div1">
<form action='index.php' method=post><input type='hidden' value='0' name='test'>
<input type='submit' value='Hello world'></form>
</div>
<div id="div1">
<form action='index.php' method=post><input type='hidden' value='1' name='test'>
<input type='submit' value='Hello world'></form>
</div>

The only difference between buttons is value='0' and value='1', and It's in form. How would I be able to click the second button when my code is just clicking the first button it finds?

Share this post


Link to post
Share on other sites
Danp2

Add a counter to your code and then only execute the _IEAction / ExitLoop combo when the counter equals 2. You could also use _IEFormGetCollection to retrieve the desire form and then call _IEFormSubmit.

$oLink = $oLink

What's this line supposed to be doing?

Share this post


Link to post
Share on other sites
zhaeldd

Add a counter to your code and then only execute the _IEAction / ExitLoop combo when the counter equals 2. You could also use _IEFormGetCollection to retrieve the desire form and then call _IEFormSubmit.

$oLink = $oLink
What's this line supposed to be doing?
How should I add the counter? I had that on mind but I couldn't create it. I thought about for loop but I guess I just wasn't creative enough.

Edit: I guess that line is useless.

Edited by zhaeldd

Share this post


Link to post
Share on other sites
Danp2

Here's one way:

$oFlag = False
$oLinks = _IETagNameGetCollection($oIE, "input")
 
 For $oLink In $oLinks
    If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then
        If $oFlag Then
            _IEAction($oLink, "click")
            ExitLoop
        Else
            $oFlag = True
        EndIf
    EndIf
 Next

Share this post


Link to post
Share on other sites
zhaeldd

 

Here's one way:

$oFlag = False
$oLinks = _IETagNameGetCollection($oIE, "input")
 
 For $oLink In $oLinks
    If String($oLink.type) = "submit" And String($oLink.value) = "Hello world" Then
        If $oFlag Then
            _IEAction($oLink, "click")
            ExitLoop
        Else
            $oFlag = True
        EndIf
    EndIf
 Next

Thanks for your help! Worked just as it should.

Edited by zhaeldd

Share this post


Link to post
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
Sign in to follow this  

×