Jump to content

Recommended Posts

Posted

I have some code that I've created and am not sure why its not selecting all my checkboxes:

<form action="/action_page.php">
<input id="selectAll" type="checkbox">
  <input type="checkbox" name="a01" value="Bike">
  <label for="vehicle1"> I have a bike</label><br>
  <input type="checkbox" name="a01" value="Car">
  <label for="vehicle2"> I have a car</label><br>
  <input type="checkbox" name="a01" value="Boat">
  <label for="vehicle3"> I have a boat</label><br><br>
  <input type="submit" value="Submit">
</form>

The input id is selectAll selects all the checkboxes, but for some reason its only selecting the checkbox with the id of "selectAll". How do I select the other checkboxes? Here is my code:

#include <IE.au3>

$url = "http://127.0.0.1/test.html"
$oIE = _IECreate ($url, 1)

$oForm = _IEFormGetCollection($oIE, 0)
$check = _IEFormElementCheckBoxSelect($oForm, 0, "selectAll", 1, "byIndex", 0)

Why is it not selecting all the checkboxes? Any help would be appreciated 😃

Posted
12 minutes ago, Danp2 said:

You have the last parameter, $iFireEvent, set to 0. This prevents the associated events from firing. Try changing it to a 1.

That worked. What happens if i have a different number set of checkboxes? Some days I may have 2 others I may get 10, etc...

Posted
10 hours ago, Danp2 said:

In the context of a "Select All" checkbox, it shouldn't matter. If I misunderstood your post, then please elaborate with an example.

The issue that I'm having is I'm having to manually write out:
$check = _IEFormElementCheckBoxSelect($oForm, 1, "selectAll", 1, "byIndex", 0)

with a 1 and then with a 2 and then a 3, etc...

#include <IE.au3>

$url = "http://127.0.0.1/test.html"
$oIE = _IECreate ($url, 1)

$oForm = _IEFormGetCollection($oIE, 0)
$check = _IEFormElementCheckBoxSelect($oForm, 1, "selectAll", 1, "byIndex", 0)
$check = _IEFormElementCheckBoxSelect($oForm, 2, "selectAll", 1, "byIndex", 0)
$check = _IEFormElementCheckBoxSelect($oForm, 3, "selectAll", 1, "byIndex", 0)

Is there a way to select them all without having to write each line manually based on how many checkboxes I have. Checkboxes can vary daily 😃
 

Posted

Sorry, but it's still unclear to me what the issue is. If you manually check the SelectAll checkbox, then I'm assuming that this triggers all of the other checkboxes to be checked. So this line of code would do the same thing --

_IEFormElementCheckBoxSelect($oForm, 0, "selectAll", 1, "byIndex", 1)

Note that I changed the value of the last parameter to 1 instead of 0 as you again posted above.

 

Posted
16 minutes ago, Danp2 said:

Sorry, but it's still unclear to me what the issue is. If you manually check the SelectAll checkbox, then I'm assuming that this triggers all of the other checkboxes to be checked. So this line of code would do the same thing --

_IEFormElementCheckBoxSelect($oForm, 0, "selectAll", 1, "byIndex", 1)

Note that I changed the value of the last parameter to 1 instead of 0 as you again posted above.

 

It looks like its only selecting the checkbox "selectAll" only. When I uncheck it manually and click on the "selectAll" checkbox it selects them all.

Posted
14 minutes ago, Danp2 said:

Sounds like it isn't triggering some underlying events. Can you share the contents of test.html or direct us to a website exhibiting this same behavior?

It's using the jquery library with the following event:

function(a, c) {
  da.actions(this, b, a, c)
}

 

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
×
×
  • Create New...