Activity Forums Salesforce® Discussions How can we get the Salesforce apex:repeat variable in the Javascript method?

  • Gourav

    Member
    October 3, 2016 at 1:55 pm

    Hi Mohit,

    Add a styleclass="" to your components, then use jQuery's selectors. You can't use Id because it has to be set to a static item.

    <apex:pageBlockSection columns="1">
    <apex:outputPanel id="relatedListSelect">
    <apex:repeat value="{!relatedListNames}" var="relList" id="theRelLists">
    <apex:inputCheckbox styleClass="{!relList.relListName} inputIsChecked" value="{!relList.selected}"/>
    <apex:outputText value="{!relList.relListName}"/><br/>
    </apex:repeat>
    </apex:outputPanel>
    </apex:pageBlockSection>

     

    Then in jQuery you can do:

    <script type="text/javascript">
    $('.inputIsChecked').each(function(i,o){
    $(o).is(':checked');
    //can get the name of the element here in a variety of ways,
    //split the classes and take the one that is the name of the list-element.
    });
    </script>

     

    Thanks.

Log In to reply.

Popular Salesforce Blogs

Popular Salesforce Videos