I have a list – house and I am displaying it on a table using apex:repeat. In this table, I want a user input checkbox which I have implemented using apex:inputCheckbox.
<td><apex:inputCheckbox id="CeilingHeightCostCheckbox" value="{!house.CeilingHeightCostCheck}" selected="true" disabled="{!IF(house.Pckg_Ground_Floor_Ceiling_Height_Cost != 0, false, true)}" onchange="CeilingHeightCostCheckChange"/></td>
I am trying to check the user picked state of this inputCheckbox inside javascript using –
var CheckboxState = $('[id$=CeilingHeightCostCheckbox]').is(':checked');
This is working fine if I just have 1 row in the list but when there are more than 1 rows, its giving random results. I guess because there are more than 1 checkboxes with id – CeilingHeightCostCheckbox
how can I generate unique ids in this scenario or if there is another way to show checkbox and capture its state ? Please help.
Best Answer
You can write the method as:
All events that are fired from an element have a
target
that identifies the element that fired the event, so you don't need to query the element again.