How to select a particular checkbox within a table?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to select a particular checkbox within a table?

Paatsch, Bernd
How to select a particular checkbox within a table?

I like to select one particular checkbox. The only reference I have is the name "first" or " second" as you can see in the html sample code.

The value attribute unfortunately is driven by an database and changes. Therefore I can not say that value="70" is always the first checkbox.

So the only way I can select the right checkbox is looking for the name "first/second" and then select the prior table cell checkbox.

Xpath buffs is there a way to do that?

I tried:

<td>storeAttribute</td>
<td>//tr[position()>1]/td[2][a=first]/preceding-sibling::tr/input@value</td>
<td></td>




HTML-code-sample:

<tbody>
<tr class="table_header">
        <th title="Mark group for deletion"></th>
        <th title="Click to view group properties">Name</th>
        <th>Type</th>
</tr>
<tr>
        <td><input name="cbxSelectGroup[]" value="70" type="checkbox"></td>
        <td><a href="group_example.php?id_group=70">first</a></td>
        <td>Dispatch</td>
</tr>
<tr>
        <td><input name="cbxSelectGroup[]" value="69" type="checkbox"></td>
        <td><a href="group_example.php?id_group=69">second</a></td>
        <td>Dispatch</td>
</tr>
</tbody>

***************************************
Bernd Paatsch


Reply | Threaded
Open this post in threaded view
|

Re: How to select a particular checkbox within a table?

Alexandre Garel
Paatsch, Bernd a écrit :
How to select a particular checkbox within a table?

I like to select one particular checkbox. The only reference I have is the name "first" or " second" as you can see in the html sample code.

The value attribute unfortunately is driven by an database and changes. Therefore I can not say that value="70" is always the first checkbox.

So the only way I can select the right checkbox is looking for the name "first/second" and then select the prior table cell checkbox.

Xpath buffs is there a way to do that?

I tried:

<td>storeAttribute</td>
<td>//tr[position()>1]/td[2][a=first]/preceding-sibling::tr/input@value</td>
<td></td>




I think the problem is in [a=first], you'd better have
//tr[position()>1]/td[2]/a[text()='first']/parent::td/preceding-sibling::tr/input@value
For information I tried it with lantern (http://www.opikanoba.org) to verify.

Alex.

Reply | Threaded
Open this post in threaded view
|

Re: How to select a particular checkbox within a table?

Alexandre Garel
Alexandre Garel a écrit :
Paatsch, Bernd a écrit :
How to select a particular checkbox within a table?

I like to select one particular checkbox. The only reference I have is the name "first" or " second" as you can see in the html sample code.

The value attribute unfortunately is driven by an database and changes. Therefore I can not say that value="70" is always the first checkbox.

So the only way I can select the right checkbox is looking for the name "first/second" and then select the prior table cell checkbox.

Xpath buffs is there a way to do that?

I tried:

<td>storeAttribute</td>
<td>//tr[position()>1]/td[2][a=first]/preceding-sibling::tr/input@value</td>
<td></td>




I think the problem is in [a=first], you'd better have
//tr[position()>1]/td[2]/a[text()='first']/parent::td/preceding-sibling::tr/input@value
WOOPS that was //tr[position()>1]/td[2]/a[text()='first']/parent::td/preceding-sibling::td/input@value  (last is td not tr)

For information I tried it with lantern (http://www.opikanoba.org) to verify.

Alex.