Jump to content
Sign in to follow this  
zbatev

Check a Web check box based on adjacent value

Recommended Posts

zbatev

How can I tick the check box based on the adjacent value (OPTION A, OPTION B...]

I'm asking this because I'm not in control of the site and I observed that from time to time the input ID or NAME changes.

<tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl3:my_checkbox" type="checkbox" id="dGroup__mcl3_my_checkbox" onclick="TakeAction()" value="0" />
        </td>
            <td align="left" style="width:80%;">[OPTION A]</td>
    </tr>
    <tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl4:my_checkbox" type="checkbox" id="dGroup__mcl4_my_checkbox" onclick="TakeAction()" value="1" />
        </td>
        <td align="left" style="width:80%;">[OPTION B]</td>
    </tr>
    <tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl5:my_checkbox" type="checkbox" id="dGroup__mcl5_my_checkbox" onclick="TakeAction()" value="2" />
        </td>
        <td align="left" style="width:80%;">[OPTION C]</td>
    </tr>
    <tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl6:my_checkbox" type="checkbox" id="dGroup__mcl6_my_checkbox" onclick="TakeAction()" value="3" />
        </td>
        <td align="left" style="width:80%;">[OPTION D]</td>
    </tr>
    <tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl7:my_checkbox" type="checkbox" id="dGroup__mcl7_my_checkbox" onclick="TakeAction()" value="4" />
        </td>
        <td align="left" style="width:80%;">[OPTION E]</td>
    </tr>
    <tr class="table_item">
        <td align="center" style="width:10%;">
            <input name="dGroup:_ctl8:my_checkbox" type="checkbox" id="dGroup__mcl8_my_checkbox" onclick="TakeAction()" value="5" />
        </td>
        <td align="left" style="width:80%;">[OPTION f]</td>
    </tr>
Edited by zbatev

Share this post


Link to post
Share on other sites
wakillon

Look at _IEFormElementCheckBoxSelect function.


AutoIt 3.3.14.2 X86 - SciTE 3.6.0WIN 8.1 X64 - Other Example Scripts

Share this post


Link to post
Share on other sites
zbatev

ie.au3 in the helpfile

yeah I am still lurking inside this help file

Look at _IEFormElementCheckBoxSelect function.

this is only good if the web developer has a default value and/or if there is an index but what if the checkbox is like this:

<input id="chkboxIncluded" type="checkbox" name="chkboxIncluded" onclick="javascript:msgCounterMessage();" />
        <label  for="chkboxIncluded">Include?</label></td>

Well I could use the click event in this case but I think it would be much safer to use the _IEFormElementCheckBoxSelect function to be able to explicitly assign a true/false(checked/unchecked) value to it.

Edited by zbatev

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  

×