Sign in to follow this  
Followers 0
dprski33

Check a checkbox that is not part of a form

3 posts in this topic

I have a situation where I need to check a checkbox. Unlike most of the other posts on this topic, this checkbox is NOT part of a form. There are no <form>...</form> tags present. Instead, javascript is used to "submit" the page after the checkbox is checked.

Here is a sample of the code I'm working with:

filename.txt <input type="checkbox" name="chk5" value="filename.txt|Demo1|demo2">

The checkbox name and value are dynamically generated, based on the filename and how many other files are already present.

Based on the filename, I can always figure out the checkbox value, but not necessarily the name.

Since this checkbox is not part of a form, I cannot use _IEFormElementCheckBoxSelect to check it. And since I cannot guess the checkbox name, I cannot use _IEGetObjByName.

Here's what I need:

A way to check this checkbox (and only this checkbox since there may be others) when this page is loaded without using _IEFormElementCheckBoxSelect or _IEGetObjByName

Thanks for the help,

~D

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

I have a situation where I need to check a checkbox. Unlike most of the other posts on this topic, this checkbox is NOT part of a form. There are no <form>...</form> tags present. Instead, javascript is used to "submit" the page after the checkbox is checked.

Here is a sample of the code I'm working with:

filename.txt <input type="checkbox" name="chk5" value="filename.txt|Demo1|demo2">

The checkbox name and value are dynamically generated, based on the filename and how many other files are already present.

Based on the filename, I can always figure out the checkbox value, but not necessarily the name.

Since this checkbox is not part of a form, I cannot use _IEFormElementCheckBoxSelect to check it. And since I cannot guess the checkbox name, I cannot use _IEGetObjByName.

Here's what I need:

A way to check this checkbox (and only this checkbox since there may be others) when this page is loaded without using _IEFormElementCheckBoxSelect or _IEGetObjByName

Thanks for the help,

~D

You should still be able to find it by Tag:

#include <IE.au3>

; ... $oIE = your IE instance

$sFile = "filename.txt"

$colInput = _IETagNameGetCollection($oIE, "input")
$iInputCnt = @extended
ConsoleWrite("Debug: There are " & $iInputCnt & " input tag elements." & @LF)
$i = 0
For $oInput In $colInput
    If $oInput.type = "checkbox" Then
        ConsoleWrite("Debug: input " & $i & " type = checkbox" & @LF)
        If StringInStr($oInput.value, $sFile) Then
            ConsoleWrite("Debug: input " & $i & " value contains " & $sFile & @LF)
            _IEFormElementCheckBoxSelect($oInput, $sFile)
            ExitLoop
        EndIf
    Else
        ConsoleWrite("Debug: input " & $i & " type is not checkbox" & @LF)
    EndIf

    $i += 1
Next

:)

Edited by PsaltyDS

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

Share this post


Link to post
Share on other sites

That worked great. Thanks for your help.

~D

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  
Followers 0